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 07-24-2009, 04:18 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 96
Default Accessing a view controller from App delegate class

Good afternoon everyone.
I'm trying to refresh a list from another class. There is a view controller class that adds the list controller class as a subview. I wrote a method in the App delegate that gets the list's view controller class. I'm getting a warning from this code, and the App will crash when it reaches the line in bold

Warning: tabBarItemController may not respond to '-getListViewController'
I used getter/setter methods so that listViewController should be available. So I think the problem might be how I am getting the view controller from the tabBarController.

Code:
- (void) refresListViewController {
	NSLog(@"Delegate: getting View Controller");
	tabBarItemController *vc = [tabBarController.viewControllers objectAtIndex:1];  // This might be the problem line
	if (vc != nil) {
		NSLog(@"Delegate: getting listView controller");
		ObjectListController *objViewController = [vc getListViewController]; // CODE CRASHES HERE. GETS WARNING
		[objViewController refreshTable];
	} else {
		NSLog(@"Delegate: Error, unable to get ListViewController");
	}
}

Last edited by blueFLoyd8; 07-24-2009 at 04:20 PM.
blueFLoyd8 is offline   Reply With Quote
Old 07-31-2009, 07:26 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 9
Default

I think you need to cast.

ViewController *vc = // from the tabBar class
TBIViewController *tbi = (TBIViewController *) vc;

//

and then proceed with your logic.
perimeter is offline   Reply With Quote
Reply

Bookmarks

Tags
tabbar controller, viewcontroller

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: 274
20 members and 254 guests
ADY, AragornSG, Bertrand21, Dani77, Dattee, Duncan C, fkmtc, HDshot, HemiMG, iDifferent, JasonR, macquitzon216, mer10, prchn4christ, Rudy, sacha1996, sneaky, spiderguy84, Sunny46, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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