I have done some digging, and I don't believe this question has been answered yet (though I would imagine it would be simple).
I want to select a random string from an array. For example:
NSArray *strings = @[@"String1", @"String2", @"String3"];
NSString *randomString = // how to randomly select one of the three strings in the array?
答案 0 :(得分:0)
You want arc4random_uniform()
:
NSString *randomString = strings[arc4random_uniform(strings.count)];
More info in this SO answer.