Skip to content

Instantly share code, notes, and snippets.

@tad-iizuka
Created September 22, 2016 12:00
Show Gist options
  • Save tad-iizuka/9a0525c0b1a1f221a06f7197f5e6ac49 to your computer and use it in GitHub Desktop.
Save tad-iizuka/9a0525c0b1a1f221a06f7197f5e6ac49 to your computer and use it in GitHub Desktop.
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let manager = Manager(context: context)
let textField = alert.textFields![0] as UITextField
if textField.text != "" {
manager.name = textField.text
} else {
manager.name = String(self.item.count+1)
}
manager.date = NSDate()
do {
try context.save()
} catch {
print(String(format: "Error %@: %d",#file, #line))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment