Quote:
Originally Posted by Howell
I am having trouble passing a managedObjectContext to a view controller. The examples I found in the IDC pass to a table view controller only and the templates found in Xcode only have 'Use Core Data for storage' options for navigation and window based applications.
Does anyone know if it is possible to have core data in a view based app and if so how do I pass the managedObjectContext to the view controller?
When I use
and
I get the error "error: accessing unknown 'setManagedObjectContext' class method". Thanks for the help.
|
I had this problem once but I found a fix. In the .h file: NSMangedObjectContext *managedObjectContext;
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; In the .m file, import the app delegate and write this code in the viewDidLoad method :
MyProjectAppDelegate *appDelegate = (MyProjectAppDelegate)[[UIApplication sharedApplication] delegate];
self.managedObjectContext = appDelegate.managedObjectContext;