Explanation of Cocoa @selector usage

前端 未结 6 2051
轮回少年
轮回少年 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 15:14

    You can use a selector to invoke a method on an object—this provides the basis for the implementation of the target-action design pattern in Cocoa.

    [myObject performSelector:@selector(runMYmethod:) withObject:parameters];
    

    is equivalent to:

    [myObject runMYmethod:parameters];
    

提交回复
热议问题