Code
let managedObjectContext =
(UIApplication.sharedApplication.delegate
as! AppDelegate).managedObjectContext
Error:
- Value of type
AppDelegate
has 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:
AppDelegate
doesn't have a property calledmanagedObjectContext
. CheckAppDelegate
and see if a property with the namemanagedObjectContext
exists.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