Getting the App delegate in any iOS project is a common question for most of Objective-C developer. Of course you could use "[[UIApplication sharedApplication] delegate]" method, but I've wrap this code into a more readable function.
/** Returns the App Delegate.
Usually you need casting the result, such as: MyClassAppDelegate *myAppDel = (MyClassAppDelegate*)[LMFunctions appDelegate];.
@return Returns the generic object (id) representing the App Delegate.
*/
+ (id)appDelegate {
return [[UIApplication sharedApplication] delegate];
}
Download the ready-for-use source file (.m) of Get App Delegate
very useful method. thank u for sharing
ReplyDeleteThis is pretty simple but I think it's not so easy to find and remember, so I create this useful method!
ReplyDeleteHope you'll use it :)