objective c - NSMutableDictionary objectForKey returns null with correct key -
im having weird problem nsdictionary, take @ code , console output , see yourself.
for (int y = 0; y < self.tileproperties.allkeys.count; ++y) { //i go on keys in nsdictionary,self.tileproperties. nsstring *string = [self.tileproperties.allkeys objectatindex:y]; nslog(@"keys %@",string); nslog(@"objects in array %@",[self.tileproperties objectforkey:string]); } nslog(@"object in array 2 %@",[self.tileproperties objectforkey:@"496"]);
this console outputs.
2016-09-12 17:23:00.822 greatgrimbeta[1043:130572] keys 496 2016-09-12 17:23:00.822 greatgrimbeta[1043:130572] objects in array { fire = 7; } 2016-09-12 17:23:00.823 greatgrimbeta[1043:130572] object in array 2 (null)
why getting null same key used in loop?
thank help!
the answer of joshcaswell
nsnumber *num = [nsnumber numberwithint:496]; nslog(@"object in array 2 %@",[self.tileproperties objectforkey:num]); 2016-09-12 18:14:43.217 greatgrimbeta[1156:149732] { fire = 7; }
Comments
Post a Comment