Can you access application delegate from within a UITableViewDataSource function?

The Application is a singleton which maintains a reference to the app delegate. You can always access your app delegate using:

[UIApplication sharedApplication].delegate

You may need to cast the return to your own app delegate class to get rid of warnings. Even better, write an accessor that returns your upcast app delegate:

#pragma mark access to app delegate etc.
+ (MyAppDelegateClass*) sharedAppDelegate; {
    return (MyAppDelegateClass*)[[UIApplication sharedApplication] delegate];
}

Leave a Comment