This file contains hidden or 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 Foundation | |
| let json = """ | |
| { | |
| "userId": 0, | |
| "name": "Donny" | |
| } | |
| """.data(using: .utf8)! | |
| let fakeSQLite = """ |
This file contains hidden or 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
| // Based on https://twitter.com/ravibastola/status/1249555595285291008?s=20 | |
| extension Bundle { | |
| // This is synchronous, which is bad if called on the main queue. | |
| func decodeJSON<T: Decodable>(_ type: T.Type = T.self, from filename: String) throws -> T { | |
| guard let path = self.url(forResource: filename, withExtension: nil) else { | |
| throw NSError(domain: NSCocoaErrorDomain, | |
| code: CocoaError.fileNoSuchFile.rawValue, | |
| userInfo: [NSFilePathErrorKey: filename]) | |
| } |