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

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -