Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

l0uismustdie

macrumors regular
Original poster
Nov 30, 2009
109
1
Edinburgh, UK
Hello. The app I am working on consists of a few views that I present and dismiss from my appDelegate. I am using the same strategy to present and dismiss all the view:
-create an object for the viewController
-present the view
-call a function in the appDelegate to dismiss the view when I'm finished

However, I've just implemented a table view and this doesn't seem to be working the same. This is how it is presented and dismissed:
Code:
-(void)showProjects
{
	ProjectIndex	*pController=[[[ProjectIndex alloc]init]autorelease];
	[viewController presentModalViewController:pController animated:NO];	
}
-(void)dismissProjects
{
	[viewController dismissModalViewControllerAnimated:YES];
}

This is identical to how I have been accomplishing this previously. I know for a fact I am getting to the dismiss line but it doesn't seem to dismiss that view. Is there something different about table views?

Thanks!
 
So I have solved this problem but I am not sure why. What I did was change
Code:
vmAppDelegate *appDelegate=[[[vmAppDelegate alloc]init]autorelease];
[appDelegate dismissProjects];
to
Code:
vmAppDelegate *appDelegate=[[UIApplication sharedApplication]delegate];
[appDelegate dismissProjects];

But the truth is I am not sure why this works or what the difference really is between this two declarations.
 
It seems like allocating a new instance of an app delegate would never work. I believe your second try works because that's passing the pointer to "your" app delegate..which is what you actually want.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.