我声明我的.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
中的所有变量都会收到警告:
自动合成属性'myVar'将使用合成的实例变量'_myVar',而不是现有的实例变量'myVar'
此外,viewDidLoad
中使用的变量和类名不会以颜色显示,只能以黑色显示。在其他视图控制器中,没有这样的警告。如何解决这些问题?
答案 0 :(得分:21)
编辑:
基本上,对于所有意图和目的,您应该构建一个足够新的XCode来使用新行为,在该解决方案中,您通常只需从@interface
文件中的.h
块中删除ivar ...如果由于某种原因您需要直接访问ivar,现在可以在@implementation
块中声明它...并使用@synthesize var
或@synthesize var=_var
<强> OGPost:强>
为了让它消失,你可以去所有新学校放弃iVar,或者你可以去所有旧学校并在@synthesize someIvar
区块中添加@implementation
。