我已经做了一些挖掘,我认为这个问题还没有得到解答(尽管我认为这很简单)。
我想从数组中选择一个随机字符串。例如:
NSArray *strings = @[@"String1", @"String2", @"String3"];
NSString *randomString = // how to randomly select one of the three strings in the array?
你想要arc4random_uniform()
:
NSString *randomString = strings[arc4random_uniform(strings.count)];
此 SO答案中的更多信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句