I don't think any of the snippets you have listed will work...
self._imagePicker //Does not exists, it should be self.imagePicker
_imagePicker.property //There is no property "property" in object of type UIImagePickerController
//And the same error goes for your last example.
I'm guessing you have seen it two ways that are common. self.imagePicker
or _imagePicker
. These two access points do different things and are useful in different circumstances.
self.imagePicker =
actually calls the [self setImagePicker:object]
method. If you don't create this method manually the method will be synthesized for you by the compiler.
_imagePicker =
just sets the object directly without calling that method.
So where this becomes a problem is if you implement your own [self setImagePicker:]
method. Inside that method you would do something like:
-(void)setImagePicker:(UIImagePickerController*)controller
{
self.imagePicker = controller;
}
This code is very bad. Since self.imagePicker =
gets changed by the compiler to [self setImagePicker:]
then you are calling that method recursively to no end. Your program crashes right there (after quite a while of 100% cpu usage and no UI functionality). Instead you should use the instance variable directly when you write the setter method:
-(void)setImagePicker:(UIImagePickerController*)controller
{
_imagePicker = controller;
}
I hope this explains a little.