Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- push
- 공략
- 스마트폰
- 앱스토어
- simulator
- UITableView
- 페이백
- 신도림 테크노마트
- 포켓몬 GO
- Example
- 포켓볼
- 보라카이
- Xcode
- IOS
- UIView
- error
- 신도림
- swift
- LG유플러스
- Bitcode
- GCD
- loop
- afterdelay
- Check
- 얻는법
- setting
- 샘플
- swift3
- 해몽
- 아이폰7
Archives
- Today
- Total
도래울
swift3 json 파일 읽기 본문
data에서 json은 SwiftyJSon 라이브러리를 이용.
filename : test.json
if let path = Bundle.main.path(forResource: "test", ofType: "json") {
do {
let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: NSData.ReadingOptions.mappedIfSafe)
let jsonObj = JSON(data: data!)
if jsonObj != JSON.null {
print(jsonObj.arrayObject)
} else {
print("could not get json from file, make sure that file contains valid json.")
}
}
} else {
print("Invalid filename/path.")
}
Comments