NSString *msg = [[NSString alloc]initWithFormat:@"Hello %s, What do you do", (self.isUser ? @"User" : @"Guest")];
NSLog(msg);
Whe开发者_C百科n I print the msg, it show that this is "†¶·»,", instead of user/guest, what's happen?
You need to use "%@" instead of "%s" on your format string if you are using NSString instances. Like this:
NSString *msg =
[[NSString alloc]initWithFormat:@"Hello %@, What do you do", (self.isUser ? @"User" : @"Guest")];
精彩评论