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
- setting
- 신도림
- Example
- swift3
- UITableView
- GCD
- 페이백
- 스마트폰
- UIView
- 포켓볼
- 보라카이
- 샘플
- 공략
- error
- 얻는법
- Check
- Bitcode
- afterdelay
- 해몽
- IOS
- 아이폰7
- simulator
- push
- Xcode
- swift
- 앱스토어
- 포켓몬 GO
- 신도림 테크노마트
- loop
- LG유플러스
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