Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSString with Instance Variable

So, I want to put an instance variable into a NSString like this:

NSString *theAnswer = (@"The answer is %@\n", self.answer);

I'm not sure am I right or not. I thought that NSString would work like NSLog but apparently it doesn't.

theAnswer returns as only the instance variable without "The answer is"

Can someone tell me why and how to fix this problem?

Thanks.

like image 477
TheAmateurProgrammer Avatar asked Oct 10 '10 03:10

TheAmateurProgrammer


1 Answers

NSString *theAnswer = [NSString stringWithFormat:@"The answer is %@", self.answer];
like image 182
dj2 Avatar answered Nov 09 '22 20:11

dj2