Skip to content

Calling an Objective C IMP with no parameters

Nat! edited this page Mar 11, 2017 · 1 revision

Convert

   IMP   f;
   SEL   sel;

   sel = @selector( whatever);
   f   = [obj methodForSelector:sel];
   (*f)( obj, sel); 

to

   IMP   f;
   SEL   sel;

   sel = @selector( whatever);
   f   = [obj methodForSelector:sel];
   (*f)( obj, sel, obj); 

The superflous third argument is harmless. Using obj as it's value instead of say, NULL, produces better code.