Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-09-2009, 07:34 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 3
Default Core data in view based app

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
Quote:
NSManagedObjectContext *context = [self managedObjectContext];
and
Quote:
myViewController.managedObjectContext = context;
I get the error "error: accessing unknown 'setManagedObjectContext' class method". Thanks for the help.

Last edited by Howell; 08-10-2009 at 11:35 AM. Reason: Wording fix
Howell is offline   Reply With Quote
Old 09-06-2009, 01:13 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 18
Default

Quote:
Originally Posted by Howell View Post
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;
edward is offline   Reply With Quote
Reply

Bookmarks

Tags
context, view, view controllers

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 259
14 members and 245 guests
2WeeksToGo, AdamL, ADY, BrianSlick, Dani77, Dattee, headkaze, mer10, prchn4christ, smithdale87, timle8n1, Touchmint, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,879
Threads: 89,228
Posts: 380,747
Top Poster: BrianSlick (7,129)
Welcome to our newest member, mgon987
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:50 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0