Objective-C Methods Referencing

315 Views Asked by At

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?

2

There are 2 best solutions below

2
On BEST ANSWER

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

2
On

when you declare methods in .h of a class, you give a symbol in front of every method..

- negative symbol means that it is an instance method

+ positive symbol means that it is an class method

you can call a class method like this...

[ClassName yourMethod];

EDIT:

I am not exactly sure what you are asking as I have no idea about Ruby but I think this answer should help you(I guess you are looking if a class contains certain method) https://stackoverflow.com/a/1135522/919545