Class instance methods? object methods?

According to Wikipedia :

Class methods are methods called by the class (compare this with the class instance methods or object methods).

Could you guys clarify the object methods me? And Class instance methods are Instance methods , if I am right?

+4
source share
3 answers

Trying to rephrase the above Wikipedia quote more clearly in the context of Objective-C:

Class methods are methods that belong to the class, not an instance of the class.

Instance methods are class instance methods; which is often referred to as an object. Saying "class instance methods" obviously refers to this, but is confusing.

+2
source

Yes, class instance methods = Object methods, because Object == Class. An object is an instance of a class. From wikipedia :

In object-oriented programming, a class is a construct that is used as a plan to create instances of itself — called class instances, class objects, instance objects, or simply objects.

+3
source

The class C object method uses just the class name; you do not need to instantiate the class to access these methods. But for object methods, you need to create an instance of the class, which means creating an object of the class .. In object C +/- identifiers are used for it:

 @interface AClass: NSObject + (void)classMethod; - (void)instanceMethod; @end [AClass classMethod]; AClass *object = [[AClass alloc] init]; [object instanceMethod]; 
+3
source

Source: https://habr.com/ru/post/1381021/


All Articles