gpt4 book ai didi

ios - 如何解决 "Autosynthesized property ' myVar' will use synthesized instance variable '_myVar' not existing instance variable 'myVar' "的警告?

转载 作者:技术小花猫 更新时间:2023-10-29 10:44:44 27 4
gpt4 key购买 nike

我这样声明我的 .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 中的所有变量都收到警告:

Autosynthesized property 'myVar' will use synthesized instance variable '_myVar', not existing instance variable 'myVar'

另外,viewDidLoad中使用的变量名和类名不显示颜色,只显示黑色。在其他 View Controller 中,没有这样的警告。如何解决这些问题?

最佳答案

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

OGPost:

要消除这种情况,您可以去所有新学校并放弃 iVar,或者您可以去所有旧学校并在您的 @implementation 中添加一个 @synthesize someIvar堵塞。

关于ios - 如何解决 "Autosynthesized property ' myVar' will use synthesized instance variable '_myVar' not existing instance variable 'myVar' "的警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19505995/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com