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

I want to call a method on an object that I am going through [self delegate]

. I know what class it is, so I can import the class and call it ok, but I can also use performSelector:

that doesn't require importing my class. I don't need to pass a parameter to the method. And yes, I read this one . Which one is preferable in this case?

+2


a source to share


2 answers


The method call is directly readable. performSelector:

should be reserved when you need higher order messaging.



Strictly speaking, you don't need to import the class in order to send a message to it, since sending the message is dynamic and not static, although you will get compile-time warnings that the object may not respond to the selector.

+2


a source


Generally speaking, reflexive operations such as performSelector:

are less effective than direct ones. I have to admit that I am not very familiar with objC.



0


a source







All Articles