[objc] NSString 에서 NSArray 로 변환

천현철·2021년 7월 10일
0

iOS

목록 보기
43/51

objc:

NSString* str = @"[90, 5, 6]";
NSCharacterSet* characterSet = [[NSCharacterSet
                                 characterSetWithCharactersInString:@"0123456789,"] invertedSet];
NSString* newString = [[str componentsSeparatedByCharactersInSet:characterSet]
                       componentsJoinedByString:@""];
                       
NSArray* arrayOfStrings = [newString componentsSeparatedByString:@","];
NSArray* arrayOfNumbers = [arrayOfStrings valueForKey: @"decimalNumberValue"];

https://stackoverflow.com/questions/25501898/how-to-convert-nsstring-to-nsarray

profile
기도하지말고 행동하라

0개의 댓글