我试图洗牌一个数组,但我得到一个“没有可见的@interface for 'NSArray' 在最后一个语句中声明了选择器'exchangeObjectAtIndex:withObjectAtIndex:'。
bArray 应该如何声明?
NSArray *bArray;
并且在
- (void)viewDidLoad
[self shuffleb];
然后
-(void) shufflb
{
bArray = [NSArray arrayWithObjects:
@"ca",
@"do",
@"ba",
@"tr",
@"bu",
@"bl",
@"bo",
@"pu",
nil];
NSInteger count = [bArray 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;
n = (arc4random() % nElements) + i;
[bArray exchangeObjectAtIndex:i withObjectAtIndex:n];
}