开发者

Can anybody explain about how I set Global Button's target in Objective-C?

开发者 https://www.devze.com 2023-03-16 00:45 出处:网络
If I wrote program in class (use @interface ....in .h and @implementation in .m) I can set button:target to self but if I want to use in global function, I cannot开发者_JS百科 set button:target as sel

If I wrote program in class (use @interface ....in .h and @implementation in .m) I can set button:target to self but if I want to use in global function, I cannot开发者_JS百科 set button:target as self. I got the error as self"undeclared".

I want to set the target as UIWindow or current display's view.

Can anybody help?


A target has to be an object, and an action has to be a method on that object. You can't do what you're trying to do.

If there's some pressing need for a global instance of something, consider making a singleton object and using that as your target.

0

精彩评论

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