romaonthego romaonthego - 1 year ago 90
iOS Question

performSelector vs direct call performace

Is there any significant difference in performance when you call

[someObject performSelector:@selector(testMethod:) withObject:anotherObject];


[someObject testMethod:anotherObject];



Answer Source

The first causes an extra call to objc_msgSend() that isn't necessary in the second case.

The performance difference is unlikely to remotely matter unless you are calling said method as quickly as you possibly can many 10s of thousands of times and you aren't doing any significant work in testMethod:.

I.e. don't worry about it unless you measure an actual performance problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download