Calling a UIApplicationDelegate method from a UIViewController
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.
[[(MyAppDelegate*)[UIApplication sharedApplication] delegate] doSomething]
Replace MyAppDelegate with the name of your App Delegate class
精彩评论