Plist 파일 구조와 Plist 파일에 저장된 데이터를 다루기 적합한 클래스를 설명하시오.
Opened this issue · 1 comments
sustainable-git commented
Plist 파일 구조와 Plist 파일에 저장된 데이터를 다루기 적합한 클래스를 설명하시오.
sustainable-git commented
- plist는 환경 설정 정보를 포함하는 구조화된 text 또는 binary file로, xml 구조로 된 utf-8 file입니다. key, value값으로 이루어져 있습니다.
- plist file은 NSDictionary 형태로 가져올 수 있습니다.
guard let url = Bundle.main.url(forResource: "UserInfo", withExtension: "plist") else { return }
// NSDictionary
guard let dictionary = NSDictionary(contentsOf: url) else { return }
//Struct
do {
let data = try Data(contentsOf: url)
let result = try PropertyListDecoder().decode(Model.self, from: data)
} catch {
print(error.localizedDescription)
}