【发布时间】:2010-10-21 22:21:31
【问题描述】:
在 Objective-C 中是否有规范的方法来随机化一个数组?
【问题讨论】:
-
对于 NSMutableArray 的推荐是 Fisher-Yates:
for (NSUInteger i = self.count; i > 1; i--) [self exchangeObjectAtIndex:i - 1 withObjectAtIndex:arc4random_uniform((u_int32_t)i)];
标签: iphone objective-c random