NSArray *array = [[NSArray alloc] initWithObjects:@"1",
@"2",@"3",nil];
NSMutableSet *randomSet = [[NSMutableSet alloc] init];
while ([randomSet count] < 1) {
int r = arc4random() % [array count];
[randomSet addObject:[array objectAtIndex:r]];
}
NSString *str = [randomSet anyObject];
NSLog(@"%@",randomSet);
网友评论