Skip to content

Instantly share code, notes, and snippets.

@casademora
Last active August 29, 2015 14:04
Show Gist options
  • Save casademora/40b960d49e057ecb3684 to your computer and use it in GitHub Desktop.
Save casademora/40b960d49e057ecb3684 to your computer and use it in GitHub Desktop.
Managed Object initializer
class CustomObject : NSManagedObject
{
init(inContext context:NSManagedObjectContext = SingletonContextStorage.context)
{
let klass = CustomObject.self
let entity = NSEntityDescription.entityForName(klass.entityName(), inManagedObjectContext: context)
super.init(entity: entity, insertIntoManagedObjectContext: context)
}
}
@casademora
Copy link
Author

Because everyone just seems to love singletons... :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment