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 |
Tags
- 한글
- github
- rxswift
- FLUTTER
- appstore
- Apple
- error
- Git
- geofencing
- Archive
- Code
- 맥
- mac
- 개발자
- MacOS
- Swift
- Session
- UIButton
- Firebase
- 이미지
- Realm
- darkmode
- 웹뷰
- iOS16
- IOS
- JPA
- Xcode
- shorebird
- window
- SwiftUI
Archives
- Today
- Total
EEYatHo 앱 깎는 이야기
Swift ) Dictionary, JSONString, Data - EEYatHo iOS 본문
Dictionary -> Data
/// 1
let imageData = UIImage(named: "sissor")?.jpegData(compressionQuality: 0)
let dict: [String: Any] = [
"string": "bbb",
"data": imageData,
"array": ["aaaa", "bbbb", 1234]
]
let dictData = try? PropertyListSerialization.data(fromPropertyList: dict, format: .binary, options: .zero)
/// 2
let jsonData = try? JSONSerialization.data(withJSONObject: dict)
Data -> Dictionary
/// 1
let dict = try? PropertyListSerialization.propertyList(from: data, options: .mutableContainers, format: .none) as? [String: Any]
/// 2
let dict2 = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
JsonString -> Data
let jsonStr = """
{ \"Key\": \"Value\" }
"""
let jsonData = jsonStr.data(using: .utf8)
Data -> JsonString
let jsonString = String(data: data, encoding: .utf8)'iOS, Swift' 카테고리의 다른 글
| Swift ) 애플로그인 2번째 이후 이메일 - EEYatHo iOS (1) | 2021.10.05 |
|---|---|
| Swift ) popoverPresentationController - EEYatHo iOS (0) | 2021.10.04 |
| Swift ) Set Custom UserAgent - EEYatHo iOS (0) | 2021.10.01 |
| Swift ) UINavigationBar shadowImage AutoHide - EEYatHo (0) | 2021.09.27 |
| Swift ) iOS15 NSInternalInconsistencyException, Invalid parameter not satisfying, UITextView Error - EEYatHo (0) | 2021.09.26 |
Comments