gpt4 book ai didi

objective-c - 为什么它不能从主文件中识别头文件中的@properties?

转载 作者:行者123 更新时间:2023-12-03 08:05:02 28 4
gpt4 key购买 nike

UIView.h

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface UIView : UIResponder {
IBOutlet UILabel *endLabel;
IBOutlet UIButton *goButton;
IBOutlet UITextField *textBox1;
IBOutlet UITextField *textBox2;

@property(nonatomic, retain) UILabel *endLabel;
@property(nonatomic, retain) UIButton *goButton;
@property(nonatomic, retain) UITextField *textBox1;
@property(nonatomic, retain) UITextField *textBox2;
}
- (IBAction)goButtonClicked;
@end

UIView.m
#import "UIView.h"

@implementation UIView

@synthesize textBox1, goButton;
@synthesize textBox2, goButton;
@synthesize textBox1, endLabel;
@synthesize textBox2, endLabel;
@synthesize goButton, endLabel;

- (IBAction)goButtonClicked {

}

@end

最佳答案

@synthesize有点疯狂,是吗?我确实相信您的主要问题是,在@property的结束}之后,@interface声明需要为

我很惊讶编译器没有抛出一个格陵兰大小的危险信号。

另外,您可能打算制作一个UIView的自定义子类;我将使用MyView

//MyView.m -- correct synthesize declaration
@synthesize textBox1, goButton, textBox2, endLabel;

//MyView.h -- correct interface declaration
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface MyView : UIView {
IBOutlet UILabel *endLabel;
IBOutlet UITextField *textBox1;
IBOutlet UITextField *textBox2;
IBOutlet UIButton *goButton;
}

@property(nonatomic, retain) UIButton *goButton;
@property(nonatomic, retain) UILabel *endLabel;
@property(nonatomic, retain) UITextField *textBox1;
@property(nonatomic, retain) UITextField *textBox2;

@end

关于objective-c - 为什么它不能从主文件中识别头文件中的@properties?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1116690/

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