NSMutableDictionary losing data?
sprite.extraData
Is a NSMutaleDictionary.
In one method, I do this:
[sprite.extraData setObject:@"HELLO" forKey:@"NAME"];
Now, in a different method, I do this:
for (CCSprite *anim in animations) {
NSLog(@"%@",[anim.extraData objectForKey:@"NAME"]);
}
Where sprite is a child of the NSMutableArray animations.
When I try to print the name, I get (null). Why开发者_如何学运维 is that?
Did you initialize the extraData of sprite?
Make sure you do something in the CCSprite init file like:
extradata = [[NSMutableDictionary alloc] init];
精彩评论