pixelfairy
pixelfairy

Reputation: 1625

How can I concatenate the string that I'm using to define this label text

this seems like it is probably dead simple to somebody but I'm stuck.

I have this little app that picks a random thing from an array of things and then displays it to the user in the form of a question.

NSLog(@"How about %@?", theThing);


// How About...

self.theThingLabel.text = theThing;

//How do I add a question mark to the end of that string

in the code above the NSLog string works just like I want the label to work. I take care of the "how about" part as a string above the displayed result, but I can't figure out how to add that question mark .. something like theThing+"?"

I tried a bunch of stuff but instead of getting lucky I got warned by xcode over and over.

Upvotes: 0

Views: 72

Answers (5)

Balram Tiwari
Balram Tiwari

Reputation: 5667

 NSString *what= @"What";
 NSString *finalString = [NSString stringWithFormat:@"How about %@ ..?", what];
 NSLog(@"%@", finalString);

Hope that helps

Upvotes: 0

Akshit Zaveri
Akshit Zaveri

Reputation: 4244

theThing = [NSString stringWithFormat:@"How about %@?",theThing];

NSLog(@"%@", theThing);

then

self.theThingLabel.text = theThing;

Hope it helps..

Upvotes: 0

Samkit Jain
Samkit Jain

Reputation: 2523

Use this :

 self.theThingLabel.text = [NSString stringWithFormat:@"How about %@  ?", theThing];

Upvotes: 0

rahul
rahul

Reputation: 178

Try this

self.theThingLabel.text = [theThing stringByAppendingString:@" ?"];

Upvotes: 1

CoolMonster
CoolMonster

Reputation: 2266

self.theThingLabel.text = [NSString stringWithFormat:@"How about %@?",theThing];

This is very easy

Upvotes: 0

Related Questions