Skip to content

Instantly share code, notes, and snippets.

View ravisharmaa's full-sized avatar
🌍
मदेक वर्ज किमिदं व्रतं ते ?

Ravi Bastola ravisharmaa

🌍
मदेक वर्ज किमिदं व्रतं ते ?
View GitHub Profile
import Foundation
let json = """
{
"userId": 0,
"name": "Donny"
}
""".data(using: .utf8)!
let fakeSQLite = """
// 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])
}