在objective-c中的按钮中显示随机字符串
我有下面的代码在按钮上显示数组中的随机字符串,但我无法找出错误所在(下面不包括声明的数组)。最后一行肯定有问题。谢谢在objective-c中的按钮中显示随机字符串,objective-c,button,random,output,Objective C,Button,Random,Output,我有下面的代码在按钮上显示数组中的随机字符串,但我无法找出错误所在(下面不包括声明的数组)。最后一行肯定有问题。谢谢 int index = [self.colorlist count]; int random = (arc4random() % index); NSString *color1 = [self.colorlist objectAtIndex:random]; [Button1
int index = [self.colorlist count];
int random = (arc4random() % index);
NSString *color1 = [self.colorlist objectAtIndex:random];
[Button1 setTitle:@"%@", color1 forState:UIControlStateNormal];
接受NSString
,而不是(@“%@”,color1
):
[Button1 setTitle:color1 forState:UIControlStateNormal];