For this line of code:
NSHost *now = [NSHost currentHost];
Why is it that the method, currentHost, returns a pointer to NSHost and not to currentHost?
For this line of code:
NSHost *now = [NSHost currentHost];
Why is it that the method, currentHost, returns a pointer to NSHost and not to currentHost?
It is a class method:
Returns an NSHost object representing the host the process is running on.
That is what the method was designed it do.
The method does not return a pointer to NSHost
, what is a type and class object, but to an instance object of the class NSHost
. This instance object is the current host.
(int *
is not a pointer to int
, but a pointer to a C object of the type int
.)
NSHost is a class name and currentHost is a static method of that class. So all objects of type NSHost share one currentHost. For example you can check the self
value gainst NSHost to see if your object is the currentHost or something else.