16

.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は色で表示されず、黒色で表示されます。他のView Controllerでは、このような警告はありません。これらの問題を解決するには?

4

1 に答える 1

23

編集: 基本的に、すべての意図と目的のために、新しい動作を使用するのに十分な新しい XCode で構築する必要があります。そのソリューションでは、通常@interface、ファイル内のブロックから ivar を削除するだけ.hです...何らかの理由で必要な場合ivar に直接アクセスして、@implementationブロック内で宣言できるようになりました...そして@synthesize varorを使用します@synthesize var=_var

OG投稿:

それをなくすには、すべて新しい学校に行って iVar を削除するか、すべて古い学校に行っ@synthesize someIvar@implementationブロックに を追加することができます。

于 2013-10-21T22:47:23.197 に答える