Wednesday, January 8, 2014

iPhone string concatenation problem

NSString * a = @ "aaa";
NSString * b = @ "bbb";
NSString * c;
C how to make the results as "aaabbb"?
Reply:
c = [a stringByAppendingString: b];
Reply:
or c = [NSString stringWithFormat: @ "% @% @", a, b];

Reply:
Upstairs 2 are correct. . .

However, add that. . . . c = [a stringByAppendingString: b]; need to b judgment, b can not be a wild pointer, or will address cross-border

or c = [NSString stringWithFormat: @ "% @% @", a, b]; may output two (nul) (nul)
Reply:
c = [NSString stringWithFormat: @ "% @% @", a, b];
Reply:
Closed posted
Reply:
The reply was deleted at the moderator 2012-04-01 10:30:29

No comments:

Post a Comment