Last active
December 16, 2015 13:43
-
-
Save sergdort/f38110981de143c407a0 to your computer and use it in GitHub Desktop.
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
extension User { | |
@NSManaged var lastName: String? | |
@NSManaged var name: String? | |
@NSManaged var userId: NSNumber? | |
@NSManaged var createdEvents: NSSet? | |
@NSManaged var homeCity: City? | |
} | |
extension User { | |
override class var map:[String : String] { | |
return [ "userId" : "id", | |
"lastName" : "last_name", | |
"homeCity" : "home_city", | |
"createdEvents" : "events"] | |
} | |
override class var relatedByAttribute: String { | |
return "userId" | |
} | |
override class var relatedJsonKey: String { | |
return "id" | |
} | |
} | |
... | |
let data:NSData = ... | |
let context = .. | |
do { | |
let user:User? = try SwiftImport<User>.importObject | |
<^> context | |
<*> JSONObject -<< JSONObjectWithData -<< data | |
} catch { | |
// handle error | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment