So I'm just playing around with some iOS stuff and doing some beginner stuff. But I'm not sure when or why you can use self references.
Here's an example from the "The Elements" example:
The class has two properties:
portraitWindow
tabBarController
Then when they go to set it up they use:
self.portraitWindow = localPortraitWindow;
... and two lines later:
[portraitWindow setBackgroundColor:[UIColor blackColor]];
^Why not use self.portrait here? Is it because this is the objective-c style [] message and above was the dot.syntax style? I can accept that...
but THEN on the next line they use the other property:
tabBarController = [[UITabBarController alloc] init];
WHAT! That's not [objective-c [] messages, but it doesn't use self. either...
but if i remove the self. from the very first example (self.portraitWindow = x) and just have "portraitWindow = x" like the tabBarController line, it crashes.
(Adding self. to the second and third examples works fine, so really, I have no idea when/where I should be using it and why or why not.)
Any insight?
Here's an example from the "The Elements" example:
The class has two properties:
portraitWindow
tabBarController
Then when they go to set it up they use:
self.portraitWindow = localPortraitWindow;
... and two lines later:
[portraitWindow setBackgroundColor:[UIColor blackColor]];
^Why not use self.portrait here? Is it because this is the objective-c style [] message and above was the dot.syntax style? I can accept that...
but THEN on the next line they use the other property:
tabBarController = [[UITabBarController alloc] init];
WHAT! That's not [objective-c [] messages, but it doesn't use self. either...
but if i remove the self. from the very first example (self.portraitWindow = x) and just have "portraitWindow = x" like the tabBarController line, it crashes.
(Adding self. to the second and third examples works fine, so really, I have no idea when/where I should be using it and why or why not.)
Any insight?
Last edited: