How to declare a class method and an instance method

suggest change

instance methods use an instance of a class.

@interface MyTestClass : NSObject

- (void)testInstanceMethod;
    
@end

They could then be used like so:

MyTestClass *object = [[MyTestClass alloc] init];
[object testInstanceMethod];

A class method can be called with just the class name.

@interface MyClass : NSObject

+ (void)aClassMethod;

@end

They could then be used like so:

[MyClass aClassMethod];

Class methods include convenience constructors on Foundation classes, such as +[NSString stringWithFormat:] and +[NSArray arrayWithArray:].

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents