Skip to content

Instantly share code, notes, and snippets.

@tad-iizuka
Created September 21, 2016 08:13
Show Gist options
  • Save tad-iizuka/ca8a4abdd948485c1ad4796eb48f602b to your computer and use it in GitHub Desktop.
Save tad-iizuka/ca8a4abdd948485c1ad4796eb48f602b to your computer and use it in GitHub Desktop.
Read Core Data with Swift3.0
func loadCoreData() {
let fetchRequest: NSFetchRequest<Manager> = Manager.fetchRequest()
do {
self.item = try (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext.fetch(fetchRequest)
} catch {
print(String(format: "Error %@: %d",#file, #line))
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.tableFooterView = UIView()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.loadCoreData()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment