在我的代码中,我想对数组中的元素进行洗牌并尝试将其打印出来,但它没有正确洗牌,我尝试了 这里显示的内容。它的工作但它的值正在重复。
for(UIView *view in self.view.subviews)
{
if([view isKindOfClass:[UIButton class]])
{
button= (UIButton *)view;
if (button.tag >=1 && button.tag <=20)
{
for (NSUInteger i = 0; i < count; ++i)
{
[texts rotate];
// Select a random element between i and end of array to swap with.
int nElements = count - i;
int n = (arc4random() % nElements) + i;
[texts exchangeObjectAtIndex:i withObjectAtIndex:n];
//int myTag= j+1;
//button = [self.view viewWithTag:myTag];
name=[NSString stringWithFormat:@"%@",[texts objectAtIndex:n]];
[button setTitle:name forState:UIControlStateNormal];
NSLog(@"current name :%@",name);
}
}
}
}
洗牌后数组值重复,请帮我解决这个问题