动态获取数组里面的莫一个元素
2019-05-28 本文已影响0人
iOS_zeng
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);