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,616
6,145
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?
 

Sbrocket

macrumors 65816
Jun 3, 2007
1,250
0
/dev/null
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];
 

grimjim

macrumors member
May 24, 2003
75
0
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.