Explanation of Cocoa @selector usage

前端 未结 6 2124
轮回少年
轮回少年 2021-01-30 14:50

I\'m new to Cocoa/Cocoa Touch, and working through a development book. I\'ve come across situations where the @selector() operator is used. I\'m a bit lost on how and when the

6条回答
  •  误落风尘
    2021-01-30 14:51

    In addition to what's been said, you can also wrap up the @selector in an NSInvocation for later use. You can set the arguments to the NSInvocation a long time after it's created, and activate it when you need the message to be fired. This gives you a lot of power.

    For an introduction to the concept, Scott Stevenson has a great post entitled "Dynamic Objective-C with NSInvocation".

提交回复
热议问题