Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,704
6,296
I have this:

Code:
[secondRedButton setTitle: (@"%s Stole It!!", secondTeamName.text) forState: UIControlStateNormal];

It should make the button say "(Name of second team) Stole It!"... instead it just makes the button say "(Name of second team)". Any idea why?
 
I have this:

Code:
[secondRedButton setTitle: (@"%s Stole It!!", secondTeamName.text) forState: UIControlStateNormal];

It should make the button say "(Name of second team) Stole It!"... instead it just makes the button say "(Name of second team)". Any idea why?

That syntax can be a little flakey. I'm not quite sure what its proper use is, anyway. Use stringWithFormat: explicitly.

Code:
[secondRedButton setTitle:[NSString stringWithFormat:@"%s Stole It!!", secondTeamName.text] forState: UIControlStateNormal];
 
I thought that %s was the format specifier for a C-type character array. I'm assuming that the text property of secondTeam actually returns an NSString, in which case you might have more luck using %@.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.