2011-01-13 30 views
0


我有一个CCArray如何从CCArray得到整数 - cocos2d的

CCArray *indexs; 

然后我添加一个整数到它

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

的话,我想从这个CCArray得到这个整数

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

然后我尝试使用CCLOG

CCLOG(@"%d", firstOne); 

它示出了在终端中的随机数,然后我尝试

CCLOG(@"%@", firstOne); 

它显示0在终端,以及i试图通过firstOne到一个函数,firstOne的值不为0,那么如何我可以从我的CCArray获得一个整数值吗?谢谢

回答

1

代码为,

int firstOne = [temp1 intValue];

+0

它的工作原理,谢谢 – Lingyong 2011-01-13 03:38:30