Concatenate string in Objective-C
Unfortunately, this is not as straight forward as it seems it should be. This really comes down to roughly two approaches in my opinion:
NSString *robot= @"Ronnie"; NSString *robotname = [robot stringByAppendingString:@" is the name of a robot."];
NSString *robot= @"Ronnie"; NSString *robotname= @" is the name of the a robot."; NSString *robotknowledge = @" knows eight languages."; [NSString stringWithFormat:@"%@/%@/%@", robot, robotname, robot, robotknowledge];
cocoadevcentral.com, “Learn Objective-C”, http://cocoadevcentral.com/d/learn_objectivec/
Posted on June 20, 2011, in Programming & Development and tagged append, cocoa, concat, concatenate, format, ios, iphone, macosx, objc, objective c, string, stringByAppendingString, stringwithformat. Bookmark the permalink. Leave a comment.
Leave a comment