Code
let managedObjectContext =
(UIApplication.sharedApplication.delegate
as! AppDelegate).managedObjectContext
Error:
- Value of type
AppDelegatehas no membermanagedObjectContext,
My problem is I want to use managedObjectContext in Xcode 8, but it says AppDelegate have no such member. I want to use this because i want to create a project for ios 9 with core data.
I want the definition of managedObjectContext,please comment if you have
Explanation:
AppDelegatedoesn't have a property calledmanagedObjectContext. CheckAppDelegateand see if a property with the namemanagedObjectContextexists.Reference:
It is very important to learn the following before writing code:
Concepts - https://developer.apple.com/library/content/documentation/DataManagement/Devpedia-CoreData/coreDataOverview.html#//apple_ref/doc/uid/TP40010398-CH28-SW1
Step by step guide - https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreData/index.html#//apple_ref/doc/uid/TP40001075-CH2-SW1