这行代码给出了ans。 2(正确)
int def = arc4random() % 2;
NSLog(@"%@",[uniqueNumbers objectAtIndex:def]);
但是当我使用
int def = arc4random() % 2;
//NSLog(@"%@",[uniqueNumbers objectAtIndex:def]);
c1 = (int)[uniqueNumbers objectAtIndex:def];
NSLog(@"%d", c1);
得出115669616。其中c1是整数。问题是什么?
最佳答案
尝试c1 = [[uniqueNumbers objectAtIndex:def] intValue];
。
关于objective-c - Objective-C获取数组元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12054495/