stringByAppendingString
:#import <Foundation/Foundation.h> int main(){ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *firstName = @"Wwfwwf"; NSString *lastName = @"Liao"; NSString *fullName = [[firstName stringByAppendingString: @" "] stringByAppendingString: lastName]; NSLog(@"my name is %@\n", fullName); [pool drain]; return 0; }result:
my name is Wwfwwf Liao使用
stringWithFormat
:NSString *fullName = [NSString stringWithFormat: @"%@ %@", firstName, lastName];
沒有留言:
張貼留言