views:

269

answers:

1

I have a simple iPhone application that is very similar to the Page Control example provided by Apple. It creates a group of UIViewControllers dynamically, then adds them to a ScrollView.

When a button is touched on one of these views, I need to be able to call a method back in the UIApplicationDelegate. It will then do some calculations, and generate a new set of views to display.

I'm not sure how to make this happen. It would seem like this would work, but it doesn't:

[[self superview] doSomething];

What am I missing? Thanks.

+4  A: 
[[(MyAppDelegate*)[UIApplication sharedApplication] delegate] doSomething]

Replace MyAppDelegate with the name of your App Delegate class

Brandon Bodnár
That worked, thank you!Though I should mention -- for other beginners like myself -- I also needed to include the header file for the AppDelegate into my ViewController:#import "MyAppDelegate.h"
Axeva