Skip to content

Instantly share code, notes, and snippets.

@sergdort
Last active December 16, 2015 12:25
Show Gist options
  • Save sergdort/f3a4442f4138935d749a to your computer and use it in GitHub Desktop.
Save sergdort/f3a4442f4138935d749a to your computer and use it in GitHub Desktop.
public class SwiftImport<Element:NSManagedObject> {
public class func importObject(context:NSManagedObjectContext)
-> (dict:JSONDictionary) throws -> Element {
// TODO
}
}
// Which will look like this in caller
let data:NSData = .. // some data probably from responce
if let json:AnyObject? = try? NSJSONSerialization.JSONObjectWithData(data, options: []) } {
let users = try? SwiftImport<User>.importObject(context:context)(dict:jsonDict)
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment