本文介绍了如何修复“自动合成属性'myVar'的警告将使用合成的实例变量'_myVar',而不是现有的实例变量'myVar'"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I declare my .h file like this:

#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文件就像这样:

And my .m file here like this:

#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 中的所有变量警告:

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

Also, the variables and class names used in viewDidLoad don't display in colors, just show in black color. In other view controllers, there are no warnings like this. How to fix these problems?

推荐答案

编辑:
基本上对于所有意图和目的,你应该建立一个新的足够的XCode使用新行为,在该解决方案中,您通常只需从 .h @interface 块中删除ivar $ c> file ...如果由于某种原因你需要直接访问ivar,你现在可以在 @implementation 块中声明它...并使用 @synthesize var @synthesize var = _var

Basically for all intents and purposes you should be building on a new enough XCode to use the new behavior, in that solution you typically will just remove the ivar from the @interface block in the .h file... If for some reason you do need to access an ivar directly you can now declare it in the @implementation block... and use @synthesize var or @synthesize var=_var

OGPost:

为了让它消失你可以去所有新学校放弃iVar,或者你可以去所有的旧学校并添加 @synthesize someIvar @implementation 块中。

to make that go away you can go all new school and drop the iVar, or you can go all old school and add an @synthesize someIvar in your @implementation block.

这篇关于如何修复“自动合成属性'myVar'的警告将使用合成的实例变量'_myVar',而不是现有的实例变量'myVar'&quot;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 23:00