3 ms·
Those first two and following aren't equivalent, are they? Wouldn't they compile, respectively, to: objc_msgSend(self, @selector(bar)); And: objc_msg
by natesm 15y ago
Those first two and following aren't equivalent, are they? Wouldn't they compile, respectively, to:
objc_msgSend(self, @selector(bar));
And:
objc_msgSend(self, @selector(performSelector:), @selector(bar));
?
- Zev 15y agoThe first two are the same, with a different syntax, yes. They would both become: objc_msgSend(self, @selector(bar)); However, your examples are basically explicitly passing a message (1 and 2), vs dynamically building a message to pass (3). For the second to work, the objc_msgCall function would really be: objc_msgSend(self, @selector(performSelector:), @selector(bar)); (The first example is saying to self to call the selector (method) named 'bar'. The second example is telling self to call the method 'performSelector:' with an argument of 'bar'.) The runtime may or may not be smart enough to optimize this out. It has never been a bottleneck for me to bother looking into it, and I haven't come across anything to indicate one way or the other.