Objective-C Language Declare class method and instance method How to declare class method and instance method.

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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];

Class method can be used with just the class name.

@interface MyClass : NSObject

+ (void)aClassMethod;

@end

They could then be used like so:

[MyClass aClassMethod];

class methods are the convenience methods on many Foundation classes like [NSString's +stringWithFormat:] or NSArray's +arrayWithArray



Got any Objective-C Language Question?