Skip to content

Instantly share code, notes, and snippets.

@artur-ios-dev
Created August 3, 2018 09:21
Show Gist options
  • Save artur-ios-dev/c90f02c3aade92984d96b46a2a5847e3 to your computer and use it in GitHub Desktop.
Save artur-ios-dev/c90f02c3aade92984d96b46a2a5847e3 to your computer and use it in GitHub Desktop.
private func saveSomeArticles() {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
}
// 1
let context = appDelegate.persistentContainer.viewContext
// 2
let mediumArticle = Article(context: context)
// 3
mediumArticle.title = randomString(length: 10)
mediumArticle.content = randomString(length: 50)
// 4
appDelegate.saveContext()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment