开发者

AppDelegate protocol

开发者 https://www.devze.com 2023-01-13 09:51 出处:网络
i\'ve implemented a transition methood in my a开发者_高级运维pp delegate file and from every where in the

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];
...
0

精彩评论

暂无评论...
验证码 换一张
取 消