wh1t3cat1k wh1t3cat1k - 1 year ago 109
Objective-C Question

_cmd value inside c functions

Good evening!

What's the value of

variable when I access it from C-style function's body?

Is it defined inside selectors (Objective-C) methods only?

Thank you!


This question may originate from my non-understanding of what
I would greatly appreciate if someone provided me with a good explanation source.

Answer Source

It's for Objective-C methods only, so you can't access it. The first two parameters passed to all Objective-C methods are self and _cmd, then whatever other arguments the actual method takes. Since neither self nor _cmd are passed to regular C functions, you can't access them.

There's nothing particularly magic about either variable.

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