View Full Version : %s in button name...
ArtOfWarfare
Aug 22, 2008, 08:58 PM
I have this:
[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
Aug 23, 2008, 12:09 AM
I have this:
[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.
[secondRedButton setTitle:[NSString stringWithFormat:@"%s Stole It!!", secondTeamName.text] forState: UIControlStateNormal];
grimjim
Aug 23, 2008, 09:22 AM
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 %@.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.