Recent Comments
- Today
- 0
- Total
- 229,869
Notice
개발은 너무해
특정 문자에 대한 분할(componentsSeparatedByString) 본문
반응형
let str = "man|17&woman|19"
let result = str.componentsSeparatedByString("&") print(result) // ["man|17", "woman|19] |
let charSet = NSCharacterSet(charactersInString: "|^") let result = str.componentsSeparatedByCharactersInSet(charSet) print(result) // ["man","17","woman","19"] |
let Array2D = str.componentsSeparatedByString("^").map { $0.componentsSeparatedByString("|") } print(Array2D) // [["man,"17"],["woman","19"]] |
반응형
'iOS-Develop(Swift)' 카테고리의 다른 글
Multi Return Values (0) | 2016.08.12 |
---|---|
collectionView cell 이동 (0) | 2016.08.04 |
특정 문자에 대한 분할(componentsSeparatedByString) (0) | 2016.08.03 |
[ERROR] pod install 시 Unable to satisfy the following requirements (0) | 2016.08.01 |
How to kill your app when it enters background mode (0) | 2016.07.15 |
navigation bar 배경색상 조절 (0) | 2016.07.06 |
0 Comments