NSString stringWithFormat

Leo picture Leo · Apr 29, 2010 · Viewed 62.3k times · Source

I don't know what I am missing here. I am trying to concatenate strings using [NSString stringWithFormat] function. This is what I am doing.

NSString *category = [row objectForKey:@"category"];
NSString *logonUser = [row objectForKey:@"username"];
user.text = [NSString stringWithFormat:@"In %@ by %@", category, logonUser];

The problem here is that it always print only one variable. Say if there is "Sports" in category and "Leo" in logonUser it will print "In Sports" and skip the remaining text. It should print "In Sports by Leo".

Answer

lucius picture lucius · Apr 29, 2010

Is user a UILabel? Make sure that your text isn't wrapping or being clipped. Try making the UILabel bigger.