반응형
목표-C 분할()?
목적어 c에 있는 문자열을 배열로 분할할 수 있는 방법이 있습니까?제 말은 이와 같습니다. 문자열 Yes:0:42:value를 (Yes,0,42,value)의 배열에 입력하시겠습니까?
NSArray *arrayOfComponents = [yourString componentsSeparatedByString:@":"];
문자열에 포함되는 위치@"one:two:three"
및 OfComponents 배열은 다음을 포함합니다.@[@"one", @"two", @"three"]
그리고 각각을 사용하여 액세스할 수 있습니다.NSString *comp1 = arrayOfComponents[0];
(https://developer.apple.com/documentation/foundation/nsstring/1413214-componentsseparatedbystring)
사용해 보십시오.
NSString *testString= @"It's a rainy day";
NSArray *array = [testString componentsSeparatedByString:@" "];
문자열로 구분된 구성 요소 시도:
사용: [[stringcomponentSeparatedByString:@", [0];
첫 번째 단어에 액세스하려는 경우:
[[string componentsSeparatedByString:@" "] objectAtIndex:0];
언급URL : https://stackoverflow.com/questions/3558888/objective-c-split
반응형
'code' 카테고리의 다른 글
adplyrtbl 열을 벡터로 추출합니다. (0) | 2023.06.17 |
---|---|
Oracle 사용자 계정 상태를 EXPIRE(GRACE)에서 OPEN으로 변경 (0) | 2023.06.17 |
x86의 MOV가 정말 "무료"가 될 수 있습니까?왜 나는 이것을 전혀 재현할 수 없습니까? (0) | 2023.06.17 |
여러 클래스 제거(jQuery) (0) | 2023.06.17 |
SignalR 허브에 연결된 수신기, 클라이언트 수 가져오기 (0) | 2023.06.17 |