我有以下代码,旨在从数组中选择一个随机字符串。
NSArray *popupMessages = [NSArray arrayWithObjects:
@"Shoulda' been bobbin' and weaving! Need anything from the shop?",
@"Don't forget you can use old boss's guns! Available in the shop!",
@"Hey Chaz, you Bojo! You need more POWER! Come by the shop for some better weapons!",
@"Aw… lame. Maybe I got something that can help you out here at my shop!",
nil];
int pmCount = popupMessages.count; // Breakpoint Here - pmCount = 971056545
int messageIndex = arc4random() % pmCount; // Breakpoint Here - same as above
我正在使用 ARC 和 cocos2d。关于为什么数组的计数返回如此巨大的数字的任何想法?谢谢!