如何解决“自动合成属性myVar”的警告将使用合成的实例variables“_myVar”,而不是现有的实例variables“myVar”“?

我声明我的.h文件是这样的:

#import <UIKit/UIKit.h> @interface NavigationTripViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource>{ NSArray *questionTitleTrip; NSArray *questionDescTrip; NSMutableArray *answerTrip; NSMutableArray *pickerChoices; int questionInt; int totalInt; IBOutlet UILabel *questionNum; IBOutlet UILabel *questionTotalNum; IBOutlet UILabel *recordType; IBOutlet UITextView *questionDes; IBOutlet UIView *answerView; IBOutlet UIButton *preButton; IBOutlet UIButton *nextButton; UITextField *text; UIPickerView *picker; } @property (retain, nonatomic) NSArray *questionTitleTrip; @property (retain, nonatomic) NSArray *questionDescTrip; @property (retain, nonatomic) NSMutableArray *answerTrip; @property (retain, nonatomic) NSMutableArray *pickerChoices; @property (retain, nonatomic) IBOutlet UILabel *questionNum; @property (retain, nonatomic) IBOutlet UILabel *questionTotalNum; @property (retain, nonatomic) IBOutlet UILabel *recordType; @property (retain, nonatomic) IBOutlet UITextView *questionDes; @property (retain, nonatomic) IBOutlet UIView *answerView; @property (retain, nonatomic) IBOutlet UIButton *preButton; @property (retain, nonatomic) IBOutlet UIButton *nextButton; @property (retain, nonatomic) UITextField *text; @property (retain, nonatomic) UIPickerView *picker; -(IBAction)clickPre; -(IBAction)clickNext; @end 

我的.m文件在这里是这样的:

 #import "NavigationTripViewController.h" #import <QuartzCore/QuartzCore.h> @interface NavigationTripViewController () @end @implementation NavigationTripViewController @synthesize questionTitleTrip,questionDescTrip,answerTripl,pickerChoices,questionNum,questionTotalNum,recordType,questionDes,answerView,preButton,nextButton,text,picker; 

@synthesize中的所有variables都会收到警告:

自动合成属性“myVar”将使用合成的实例variables“_myVar”,而不是现有的实例variables“myVar”

此外, viewDidLoad使用的variables和类名称不以颜色显示,只显示为黑色。 在其他视图控制器中,没有像这样的警告。 如何解决这些问题?

编辑:基本上所有的意图和目的,你应该build立一个足够新的XCode使用新的行为,在这种解决scheme中,你通常会从.h文件中的@interface块中删除ivar …如果由于某种原因你需要直接访问一个ivar,你现在可以在@implementation块中声明它,并使用@synthesize var或者@synthesize var=_var

OGPost:

为了使这个消失,你可以去所有的新学校,放弃iVar,或者你可以去所有的老学校,并在@implementation块添加@synthesize someIvar