-- iOS (iPhone)

objective-c combine string

어린왕자악꿍 2012. 10. 15. 13:16
스트링을 조합하여 하나의 스트링으로 만들 때 아래의 방법들로 사용할 수 있다.

// formating combine
NSString *str = [NSString stringWithFormat:@"%@%@", @"Hello", @"World"];

// append combine
NSString *s1 = @"Hello";
NSString *s2 = @"World";
NSString *str = [s1 stringByAppendingString:s2];

// literal string combine
NSString *str = @"Hello"@"World";
NSString *str = @"Hello" @"World";