Develop

[ios] Objective-C 문자열 잘라서 배열(NSArray)에 넣기

by hooni posted Apr 23, 2013
?

Shortcut

PrevPrev Article

NextNext Article

ESCClose

Larger Font Smaller Font Up Down Go comment Print
1. 문자열을 식별자 기준으로 배열로 나누기
(componentsSeparatedByString 메소드 사용)
NSString *string = @"one:two:three:four";
NSArray *chunks = [string componetsSeparatedByString: @":"];



2. 배열의 객체를 합쳐 하나의 문자열로 만들기
(componentsJoinedByString 메소드 사용)
string = [chunks componentsJoinedByString: @"-"];
결과 @"one-two-three-four"