Reputation: 9
I have the following code to display a random string from my array on a button, but I can't figure out what's wrong (the declared array isn't included below). There is definitely a problem with the last line. Thanks!
int index = [self.colorlist count];
int random = (arc4random() % index);
NSString *color1 = [self.colorlist objectAtIndex:random];
[Button1 setTitle:@"%@", color1 forState:UIControlStateNormal];
Upvotes: 1
Views: 68
Reputation: 73031
setTitle:
accepts an NSString
, not a format (@"%@", color1
):
[Button1 setTitle:color1 forState:UIControlStateNormal];
Upvotes: 2