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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 01-18-2010, 12:30 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2009
Posts: 5
LokiHobbs is on a distinguished road
Default Initiating managedObjectContext

I am using the tab bar application template and have added core data. Using the Core Data Books template, I am trying to create the sqlite3 database with the following:

Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
	
	FirstViewController *rootViewController = (FirstViewController *)[tabBarController topViewController];
	rootViewController.managedObjectContext = self.managedObjectContext;	    
   
	// Add the tab bar controller's current view as a subview of the window
    [window addSubview:tabBarController.view];
}
I have imported my firstviewcontroller.h file into the appdelegate.h file.

That is where it crashes with the message "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UITabBarController topViewController]: unrecognized selector sent to instance".

I am not used to working with a XIB file so my thoughts are something is conflicting with my code and the XIB. Any suggestions would be appreciated.
LokiHobbs is offline   Reply With Quote
Old 05-24-2011, 11:57 AM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: UK, North East
Posts: 227
zardon is on a distinguished road
Default

Quote:
Originally Posted by LokiHobbs View Post
I am using the tab bar application template and have added core data. Using the Core Data Books template, I am trying to create the sqlite3 database with the following:

Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
	
	FirstViewController *rootViewController = (FirstViewController *)[tabBarController topViewController];
	rootViewController.managedObjectContext = self.managedObjectContext;	    
   
	// Add the tab bar controller's current view as a subview of the window
    [window addSubview:tabBarController.view];
}
I have imported my firstviewcontroller.h file into the appdelegate.h file.

That is where it crashes with the message "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UITabBarController topViewController]: unrecognized selector sent to instance".

I am not used to working with a XIB file so my thoughts are something is conflicting with my code and the XIB. Any suggestions would be appreciated.
Try changing;

[tabBarController topViewController];

to:

[navController topViewController];

You will need to define what navController is (IBOutlet UINavigationController... etc)
zardon is offline   Reply With Quote
Reply

Bookmarks

Tags
core data, managedobjectcontext

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: 331
9 members and 322 guests
2Apps1Day, akacaj, Domele, michelle, NSString, SLIC, soohyun, Techgirl-52, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,114
Posts: 402,886
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

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