In Ruby, when referring to the "downcase" method of the class "String", I write String#downcase. When talking about the "new" class method, I write String.new.
Is there something similar for Objective-C?
In Ruby, when referring to the "downcase" method of the class "String", I write String#downcase. When talking about the "new" class method, I write String.new.
Is there something similar for Objective-C?
If you are referring to a method like:
+ (void)someClassMethod;
on class MyObject then you would call it like this:
[MyObject someClassMethod];
Given a class declaration like this
@interface MyClass (NSObject)
{}
+ (id)classMethod;
- (id)instanceMethod;
@end
it is common practice to refer to classMethod
as +[MyClass classMethod]
or more compactly +classMethod
if the class is clear. Similarly, I would refer to instanceMethod
as -[MyClass instanceMethod]
or -instanceMethod
.