开发者

How to get integer from CCArray - cocos2d

开发者 https://www.devze.com 2023-02-03 19:00 出处:网络
i have a CCArray CCArray *indexs; then i add a integer into it int x = 0; [indexs addObject:[NSNumber numberWithInteger:x]];

i have a CCArray

    CCArray *indexs;

then i add a integer into it

    int x = 0;
    [indexs addObject:[NSNumber numberWithInteger:x]];

then i want to get this integer from this CCArray

    id temp1 = [indexs objectAtIndex:0];
    int firstOne = (int) temp1;

then i try using CCLOG

    CCLOG(@"%d", firstOne);

it shows a random number in the terminal, then i try

    CCLOG(@"%@", firstOne);

it shows 0 in the terminal, and i tried to pass firstOne into a function, firstOne's value is not 0, then how can i get a integer value from my CCArray? th开发者_StackOverflowank you


Code as,

int firstOne = [temp1 intValue];

0

精彩评论

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