objective c - What does the [SomeClass self] syntax do? -
i studying sample code provided apple sketch , stumbled upon syntax haven't seen before. it's in sktgraphicview.m
in function moveselectedgraphicswithevent:
nsrect selbounds = [[sktgraphic self] boundsofgraphics:selgraphics];
i have never seen [someclass self]
syntax before. in case self
subclass of nsview
, boundsofgraphics:
class method sktgraphic
subclass of nsobject
.
the self
method defined in nsobject
protocol, every object instance of class or class object (of type class
) supports method. returns object called on, i.e. like:
- (id) self { return self; }
so self
on instance returns instance, , on class object returns class object.
the following therefore holds: [x self] == x
yes
instance , class objects x
and line equivalent to:
nsrect selbounds = [sktgraphic boundsofgraphics:selgraphics];
so what does. why apple wrote way, that's different question...
Comments
Post a Comment