我使用四个按钮并打乱按钮标签值以在每次点击时查看不同的值,因为我从数组中显示按钮的值,当我试图打乱标签值时,我得到了以下错误。
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray exchangeObjectAtIndex:withObjectAtIndex:]: index 16 beyond bounds [0 .. 3]'
我洗牌标签值数组的代码,
words = [[NSMutableArray alloc] initWithObjects:@"1", @"2", @"3",@"4", nil] ;
NSUInteger count = [questar count];
for (NSUInteger i = 0; i < count; ++i) {
// Select a random element between i and end of array to swap with.
NSInteger nElements = count - i;
NSInteger n = (arc4random() % nElements) + i;
[words exchangeObjectAtIndex:i withObjectAtIndex:n];
}
我应该做些什么改变?有谁能帮我解决