Noob Properties Error

I am working with existing code. Here the popovercontroller was declared in the .h file, and this gives me an error in the implementation string.

.h file

@property (nonatomic, strong) VFImagePickerController *imagePicker; @property (nonatomic, strong) UIPopoverController *popoverController; @property (nonatomic, strong) UINavigationController *targetVC; 

.m file:
The error

Please suggest how to fix this.

+4
source share
4 answers

Uncomment the synthesis line and remove the underline to look like this: @synthetize popoverController;

And replace each _popoverController var variable name in the .m file with popoverController

+3
source

It seems your class is a subclass of UIViewController . UIViewController has a closed, undocumented ivar _popoverController . Since you are trying to create ivar in your class with the same name, you get an error.

The simplest thing is to rename your popoverController property to something else. Otherwise, your application may be flagged to use a private API.

+12
source

This problem occurs because your superclass, UIViewController, already has an instance variable named _popoverController . As a result, neither the default synthesis nor your explicit (commented out) @synthesize directive has access to the instance variable that they want to use to provide the popoverController property.

You can solve this by renaming your property or by explicitly synthesizing the property to use a different instance variable name:

 // Either @property (nonatomic, strong) UIPopoverController *localPopoverController // Or @synthesize popoverController = _localPopoverController; 

(Also note that a β€œlocal” prefix is ​​not necessarily the best practice for your property names or instance variables; take a second to review your preferred naming convention and choose the property / instance variable name accordingly.)

+9
source

Do not specify an instance variable (or property) of popoverController. As mentioned above, the UIViewController has an instance variable declared as _popoverController. (Who knows why.)

It would be wise not to give your popover controller a universal name anyway, because, for example, if you decide to add several elements to the toolbar, you need to create more than one popover controller to do this.

If you look at the sample Apple code, you will see how they do it:

http://developer.apple.com/library/ios/#samplecode/Popovers/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010436

The private properties section in the DetailViewController opens. There you will see three controller objects and not one with the common name "popoverController". This will cause problems.

0
source

All Articles