shuffle NSMutableArray without repetition and showing in a UIButton
问题 In my view, i have 12 buttons,and a array contains 6 names , i want to print the array names in UIButton title. Here's my code: texts = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",nil]; UIButton *button; NSString *name; NSUInteger count = [texts count]; int i=0; for(UIView *view in self.view.subviews) { if([view isKindOfClass:[UIButton class]]) { button= (UIButton *)view; if(button.tag >= 1||button.tag <= 20) { int value = rand() % ([texts count] -1) ; int myTag= i+1