Created
October 4, 2023 04:16
-
-
Save MSicc/b60411608edd406528df783a521d33ee to your computer and use it in GitHub Desktop.
DataManager from the iOS 15 Swift Book....
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DataManager.swift | |
// LetsEat | |
// | |
// Created by MSiccDev on 07.09.23. | |
// | |
import Foundation | |
protocol DataManager { | |
func loadPlist(file name: String) -> | |
[[String: AnyObject]] | |
} | |
extension DataManager{ | |
func loadPlist(file name: String) -> [[String: AnyObject]] | |
{ | |
guard let path = Bundle.main.path(forResource: name, ofType: "pList"), | |
let itemsData = FileManager.default.contents(atPath: path), | |
let items = try! PropertyListSerialization.propertyList(from: itemsData, format: nil) | |
as? [[String: AnyObject]] else { | |
return[[:]] | |
} | |
return items | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment