Skip to content

Instantly share code, notes, and snippets.

@sandeeplearner
Last active September 4, 2016 19:44
Show Gist options
  • Select an option

  • Save sandeeplearner/4ca37c7814dae592a9bb4e6d7b082ee9 to your computer and use it in GitHub Desktop.

Select an option

Save sandeeplearner/4ca37c7814dae592a9bb4e6d7b082ee9 to your computer and use it in GitHub Desktop.
let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate
appDelegate?.managedObjectContext.performBlock({
let person = NSEntityDescription.insertNewObjectForEntityForName("Person", inManagedObjectContext: (appDelegate?.managedObjectContext)!) as! Person
person.name = "Sandeep"
person.age = NSNumber(integer: Int(26))
person.nickname = "Sandeep"
person.phone = "1234567890"
try! appDelegate?.managedObjectContext.save()
self.dismissViewControllerAnimated(true, completion: nil)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment