Skip to main content

Reading Files in Swift

Reading Files in Swift

func loadJsonAsync() {
DispatchQueue.global(qos: .background).async {
if let path = Bundle.main.path(forResource: "ํ•œ๊ธ€.min", ofType: "json") {
do {
let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe)
let jsonResult = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves)
if let jsonResult = jsonResult as? [String: Any], let ๋ฐ์ดํ„ฐ = jsonResult as? [String: [String: String]] {
self.ํ•œ๊ธ€ = ๋ฐ์ดํ„ฐ
}
} catch {
exit(1)
}
}
}
}