Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Noob properties error

I'm working with an existing code. Here a popovercontroller has been declared in .h file and its giving me error in implementation line.

.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.

like image 287
CalZone Avatar asked Nov 29 '22 08:11

CalZone


2 Answers

It appears that your class is a subclass of UIViewController. UIViewController has a private, undocumented ivar of _popoverController. Since you are trying to create an ivar in your class with the same name, you are getting an error.

The easiest thing to do is to rename your popoverController property to something different. Otherwise your app might get flagged for using a private API.

like image 149
rmaddy Avatar answered Dec 17 '22 11:12

rmaddy


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) @synthesize directive have access to the instance variable that they want to use to provide the popoverController property.

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

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

(Also note that the "local" prefix isn't necessarily best practice for your property names or instance variables; take a second to consider your preferred naming convention and pick a property/instance variable name appropriately.)

like image 45
Tim Avatar answered Dec 17 '22 12:12

Tim