frankWhite
frankWhite

Reputation: 1542

Who is the receiver for a class method?

If I define a class Utils like this:

@interface Utils: NSObject {

}

+ (NSInteger)getFreeSize;

who will get the message getFreeSize when I use it like this [Utils getFreeSize];?

Is any static instance created under the hood for Util's representation at runtime? Who is the target for this message?

Upvotes: 1

Views: 47

Answers (1)

Wain
Wain

Reputation: 119031

The class itself is the target, it's what you're calling the method on. There is an instance of the class object which exists, and then you can create instances of (instantiate) the class (there's a difference).

Upvotes: 2

Related Questions