PDA

View Full Version : help with strings




italiano40
Jul 23, 2008, 10:43 PM
ok, i want to add a variable into my string and i do

int i=23;
NSString *f=@"what is $i";

what am i doing wrong



lee1210
Jul 23, 2008, 10:53 PM
This isn't perl =).


int i=23;
NSString *myString = [NSString stringWithFormat:@"what is %d",i];


See:
http://developer.apple.com/documentation/Cocoa/Conceptual/Strings/Articles/FormatStrings.html#//apple_ref/doc/uid/20000943

-Lee