在Objective-C中引用类方法的"官方"语法?

mru*_*ueg 3 ruby syntax objective-c

在Ruby中,当引用类"String"的"downcase"方法时,我编写了String#downcase.在谈论"新"类方法时,我写了String.new.

Objective-C有类似的东西吗?

Bar*_*ark 12

给出这样的类声明

@interface MyClass (NSObject)
{}

+ (id)classMethod;
- (id)instanceMethod;
@end
Run Code Online (Sandbox Code Playgroud)

通常的做法是指classMethod作为+[MyClass classMethod]或更紧凑+classMethod如果类是明确的.同样,我要提到instanceMethod-[MyClass instanceMethod]-instanceMethod.


Nik*_*uhe 5

gdb使用+[MyClass foo]-[MyClass bar];