How can I make a static method in Objective-C?

前端 未结 2 854
陌清茗
陌清茗 2020-12-14 14:15

In Java, I may have a class, for example, Utility and I have a static method called changeToCapitalLetter, so I can do something like this:

<
2条回答
  •  时光取名叫无心
    2020-12-14 14:51

    In Objective-C, you call this "class methods", see here:

    @interface MyClass : NSObject
    
    + (void)aClassMethod;
    - (void)anInstanceMethod;
    
    @end
    

    The + is the important thing; you call the method like this: [MyClass aClassMethod];

提交回复
热议问题