2009-05-10 6 views

답변

259
NSArray *array1 = [NSArray arrayWithObjects:@"1", @"2", @"3", nil]; 
NSString *joinedString = [array1 componentsJoinedByString:@","]; 

componentsJoinedByString: 지정된 문자열 배열의 요소를 결합하고 상기 어레이의 문자열 표시를 리턴한다.

17

찾고있는 방법은 componentsJoinedByString입니다.

NSArray *a = [NSArray arrayWithObjects:@"1", @"2", @"3", nil];//returns a pointer to NSArray 
NSString *b = [a componentsJoinedByString:@","];//returns a pointer to NSString 
NSLog(@"%@", b); // Will output 1,2,3 
6

NSArray class reference :

NSArray *pathArray = [NSArray arrayWithObjects:@"here", 
    @"be", @"dragons", nil]; 
NSLog(@"%@", 
    [pathArray componentsJoinedByString:@" "]); 
관련 문제