Created
February 21, 2017 12:03
-
-
Save tralamazza/a16282b1ac73525f0399afabedfab37b 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
import CoreData | |
extension NSManagedObject { | |
convenience public init(insertInto context: NSManagedObjectContext?) { | |
let name = String(describing: type(of: self)) | |
let entity = NSEntityDescription.entity(forEntityName: name, in: context!) | |
self.init(entity: entity!, insertInto: context) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to create a managed object you simply do: