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
import PlaygroundSupport | |
import Foundation | |
func load<T: Decodable>(from file: URL) -> T? { | |
guard let data = NSKeyedUnarchiver.unarchiveObject(withFile: file.path) as? Data else { return nil } | |
do { | |
let products = try PropertyListDecoder().decode(T.self, from: data) | |
print("Successful load") | |
return products | |
} catch let e { |