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 |
Tags
- FLUTTER
- JPA
- 웹뷰
- github
- Xcode
- darkmode
- rxswift
- SwiftUI
- Swift
- appstore
- IOS
- Session
- Apple
- view
- error
- window
- Code
- 한글
- Firebase
- UIButton
- mac
- stack
- Git
- iOS16
- 개발자
- Archive
- MacOS
- Python
- Realm
- Notification
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