I'm confused with the usage of properties in Objective-C. If I create a new IBOutlet
like this:
IBOutlet UISlider *uploadSlider;
And then define a property for the slider so I can use its getters and setters:
@property (nonatomic, strong) IBOutlet UISlider *uploadSlider;
And then @synthesize
it in the implementation file, what is the proper way to actually use the property? For example, if I want to change the slider's track image, do I call
[uploadSlider setMaximumTrackImage:[UIImage imageNamed:@"An image"] forState:UIControlStateSelected];
Or:
[self.uploadSlider setMaximumTrackImage:[UIImage imageNamed:@"An image"] forState:UIControlStateSelected];
The method that I prefix with self
is only available after defining properties, which makes me think that it is the correct choice. But I don't understand why. Do I even need properties to access these methods?
Also, if I am using dot syntax to get or set information pertaining to an object, must I define properties for the object even though I am not directly accessing one of its instance methods?