objective-cdocumentationselectormethod-names

Objective-C Methods Referencing


I know how to write selector names in Objective-C like mergeThis:withThat:, but can somebody tell me, how can I reference (e.g. in documentation, text or commit message) that a method belongs to a class and is either an instance method or a class method?

In Ruby I would write String#reverse for instance methods or File::exists?(file_name) for class methods. See this question.

Is there a standardized way or a convention to do so in Objective-C?


Solution

  • In Objective-C you'd write something like this for instance method:

    -[MyClass myMethodWithArg:andAnotherArg:]
    

    and this for class method:

    +[MyClass staticMethodWithArg:andAnotherArg:]
    

    update to comment

    I am using NSLog's __PRETTY_FUNCTION__ output format (per Zarra Studio's coding guidelines) which gives that kind of output. Apple's documentation provides following format, but it's class-context dependent:

    enter image description here