Properties 属性实现必须在接口错误中声明
属性实现必须在接口错误中声明 我有这个错误,我是新的xcode,所以我不知道该怎么做 我在一个类中有很多代码,然后我把它移到另一个类中,现在我有很多错误。这是没有道理的,因为一切看起来都应该如此Properties 属性实现必须在接口错误中声明,properties,implementation,Properties,Implementation,属性实现必须在接口错误中声明 我有这个错误,我是新的xcode,所以我不知道该怎么做 我在一个类中有很多代码,然后我把它移到另一个类中,现在我有很多错误。这是没有道理的,因为一切看起来都应该如此 #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize MenuScreenButton; @synthesize HowToPlayButton
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize MenuScreenButton;
@synthesize HowToPlayButton;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(IBAction)HowToPlayButtonPressed:(id)sender
{
HowToPlayViewController *HowToPlayView=[[HowToPlayViewController alloc]initWithNibName:nil bundle:nil];
HowToPlayView.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentViewController:HowToPlayView animated:YES completion:NULL];
}
-(IBAction)MenuScreenButtonPressed:(id)sender
{
MenuScreen *MenuScreenView=[[MenuScreen alloc]initWithNibName:nil bundle:nil];
MenuScreenView.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentViewController:MenuScreenView animated:YES completion:NULL];
}
@end
下面是.h文件:
#import <UIKit/UIKit.h>
#import "HowToPlayViewController.h"
#import "MenuScreen.h"
@interface ViewController : UIViewController
{
IBOutlet UIButton *HowToPlayButton;
IBOutlet UIButton *MenuScreenButton;
}
@property(retain,nonatomic) IBOutlet UIButton *MenuScreenButton;
@property(retain,nonatomic) IBOutlet UIButton *HowToPlayButton;
-(IBAction)HowToPlayButtonPressed:(id)sender;
-(IBAction)MenuScreenButtonPressed:(id)sender;
@end
您需要在@synthesis MenuScreenButton后面加一个分号,而不是逗号,还有ViewController中的内容。hI更正了逗号,但错误仍然显示为sadlyOk。首先,属性应该是小写的。其次,您使用的是最新版本的Xcode。其他错误是,对于以前在此类中但已移动的几个控制器,显示“使用未声明的标识符”?您可能缺少导入,或者如果不需要引用,则删除引用。顺便说一句,如果您使用的是最新版本的Xcode,那么您可以用更少的代码声明属性-您不需要@interface{}块中的UIButton声明,-只需要@property,也不需要@synthesis。您将属性声明为retain,因此我假设您没有使用ARC