Hidden method arguments

January 31st, 2011

Objective-C automatically passes two hidden method arguments with ever method call:

  • self - the object that the method is executing inside
  • _cmd - method's message call

Here's an example of using _cmd:

NSLog(@"%@", NSStringFromSelector(_cmd));

What do you think? Let me know by getting in touch on Twitter - @wibosco

William Boles

William has been an iOS developer since 2010, after all these years he just hopes that the String API will stop changing now.