Can we avoid objmsg function overhead by using sel and imp means selector and implementation pointer.Please tell how we can avoid it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
access the IMP for an instance of a specific class using:
+ (IMP)instanceMethodForSelector:(SEL)aSelector;ideally, you will cast the result of instanceMethodForSelector: to an exact typedef of the function you call so the compiler can get the sig right.
once you have the object, SEL and IMP, then use the IMP as an ordinary C function pointer.
where the first message to the IMP function returned is the object(=
self), and the second argument is the selector(=_cmd). these are the 2 hidden objc arguments.