Описание тега self
In many object-oriented programming languages, self
(also called this
or Me
) is a keyword that is used in instance methods to refer to the object on which they are working. Languages like smalltalk and others such as object-pascal, python and ruby use self
. objective-c uses self
or super
; c++ and languages which derive in style from it (such as java, c#, and php) generally use this
. Visual Basic uses Me
.
Invoking a method on the self
searches for the method implementation of the method in the usual manner, starting in the dispatch table of the receiving object’s class.
Example:
[self startThread];
self.hostReach = YES;
BOOL value = self.hostReach;
Here, self
is a variable name that can be used in any number of ways, even assigned a new value.
Inside an instance method, self
refers to the instance; inside a class method, self
refers to the class object.