Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.