开发者

NSMutableDictionary losing data?

开发者 https://www.devze.com 2023-04-07 13:28 出处:网络
sprite.extraData Is a NSMutaleDictionary. In one method, I do this: [sprite.extraData setObject:@\"HELLO\" forKey:@\"NAME\"];
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];
0

精彩评论

暂无评论...
验证码 换一张
取 消