Reputation: 141
According to Wikipedia:
Class methods are methods that are called on a class (compare this to class instance methods, or object methods).
Could you guys please clarify object methods
to me?
And Class instance methods
are Instance methods
if i'm correct?
Upvotes: 4
Views: 239
Reputation: 4347
In objective C class method is used by just class name, you dont need to create a instance of class to access these methods.. But for object methods you need to create an instance of the class which means creating a object of class.. In objective C +/- identifiers are used for it;
@interface AClass: NSObject
+ (void)classMethod;
- (void)instanceMethod;
@end
[AClass classMethod];
AClass *object = [[AClass alloc] init];
[object instanceMethod];
Upvotes: 3
Reputation: 62469
Yes, Class instance methods = Object methods because Object == Class instance. An object is an instance of a class. From wikipedia:
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects.
Upvotes: 3
Reputation: 19789
Trying to rephrase the above Wikipedia quote more clearly in the context of Objective C:
Class methods are methods belonging to the class, rather than to an instance of a class.
Instance methods are methods of an instance of a class; which is often referred to as an object. Sayng "class instance methods" obviously refers to this, but is confusing.
Upvotes: 2