我想这是一个非常基本的问题,但我正在从 Nick Kuh 的“Foundation iPhone App Development”一书中做一个教程,我不完全理解这一行:
int count = [自我计数];
...真的以“自我”开始?
这是整个代码:
#import "NSMutableArray+Shuffle.h"
@implementation NSMutableArray (Shuffle)
- (void)shuffle {
int count = [self count];
NSMutableArray *dupeArr = [self mutableCopy];
count = [dupeArr count];
[self removeAllObjects];
for (int i = 0; i < count; i++) {
// Select a random element between i and the end of the array to swap with.
int nElement = count - i;
int n = (arc4random() % nElement);
[self addObject:dupeArr[n]];
[dupeArr removeObjectAtIndex:n];
}
}
@end