AppDelegate protocol
i've implemented a transition methood in my a开发者_高级运维pp delegate file and from every where in the code i want to call it in order to make nice and cool transitions. i call her like that
[[[UIApplication sharedApplication] delegate] transFromMainToGalery];
for example.
the problem is that im getting warning which is ok (cause it already got approved by apple) but i still want to fix it
the error:
'-transFromMainToGalery' not found in the protocol
any ideas??
thanks in advance!
In your myAppDelegate.h file, make sure you have:
- (void) transFromMainToGalery;
Then cast the generic app delegate returned by the sharedApplication delegate to your specific app delegate class:
[ (myAppDelegate *)[[UIApplication sharedApplication] delegate] transFromMainToGalery ];
Also include myAppDelegate.h in the header of your various other classes which use this message.
(substitute your app delegate class and file name for "myAppDelegate" as needed)
Add the method signature to your AppDelegate's .h file and import that file in those .m files that you call it from.
How about using UIApplication instead of UIApplicationDelegate.
@interface UIApplication (My)
-(void)myFunc;
@end
Implementing and calling are as below,
@implementation UIApplication (My)
-(void)myFunc {
}
...
[[UIApplication sharedApplication] myFunc];
...
精彩评论