开发者

Should I use performSelector: when I also can call the method normally?

I want to call a method on an object which I get through [self delegate]. I know which class it is so I can import the class and call it norm开发者_开发问答ally but I could also use performSelector: which doesn't require importing my class. I do not need to pass a parameter to the method. And yes, I did read this. Which one is preferable in this case?


Calling the method directly is more readable. performSelector: should be reserved for when you need higher order messaging.

Strictly speaking, you don't need to import the class to send it a message as message dispatch is dynamic rather than static, though you will get compile time warnings that the object may not respond to the selector.


Generally speaking, reflective operations, such as performSelector:, are less efficient than the direct ones. I have to admit that I am not very familiar with objC, though.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜