'문자열 자르기'에 해당되는 글 1건

  1. 2011.06.02 [Objective-C] 문자열 잘라서 배열(NSArray)에 넣기
Dev/iOS2011. 6. 2. 22:17

문자열을 식별자를 이용하여 배열로 나누기

componentsSeparatedByString 메소드

NSString *string = @"one:two:three:four";

NSArray *chunks = [string componetsSeparatedByString: @":"];


반대로 배열의 객체를 합쳐 하나의 문자열로 만들기

componentsJoinedByString 메소드 사용

string = [chunks componentsJoinedByString: @"-"];

결과 @"one-two-three-four"



출처 : Objective-C 2.0 (이종웅 저)

Posted by 놀란