【问题标题】:Objective C: "Property implementation must have its declaration in interface"目标 C:“属性实现必须在接口中声明”
【发布时间】:2011-09-14 16:58:08
【问题描述】:

我有以下代码:

//RootViewController.h:

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController{
    IBOutlet UITextField *login_uname;
    IBOutlet UITextField *login_pword;
    IBOutlet UIActivityIndicatorView *login_thinger;
    IBOutlet UIImageView *logo;
    IBOutlet UISwitch *login_remember;

    IBOutlet UIScrollView *scrollView;
}




-(IBAction) login_submitClick:(id)sender;
-(IBAction) doneEditing:(id)sender;
-(IBAction) clearPword:(id)sender;
-(void) showSignUp:(id)sender;

-(void)doLogout:(id)sender;

//for file handling:
-(NSString *)documentsPath;
-(NSString *)readFromFile:(NSString *)filePath;
-(void) writeToFile:(NSString *)text withFileName:(NSString *) filePath;

@end

//RootViewController.m

#import "RootViewController.h"
//#import "Main.h"
//#import "SignUp.h"
#import "ASIHTTPRequest.h"
#import "ASIFormDataRequest.h"
#import "CommonCrypto/CommonHMAC.h"
#import "Details.h"
//#import "signUpSMS.h"
#import "JSON.h"

@implementation PrestoCab3ViewController
@synthesize login_uname;   //this line throws the error in the title

...

我正在使用 XCode 4.1,想知道是否有人可以帮助我找出这个错误的根源。我对 XCode 很陌生。

非常感谢,

【问题讨论】:

  • @synthesize 应该有一个等效的属性声明。
  • 您好,谢谢您的回复。我该怎么做呢?

标签: objective-c


【解决方案1】:

您需要在界面中使用@property 声明该属性。

@property( nonatomic, retain ) IBOutlet UITextField * login_uname;

这里使用非原子,因为它是一个 IBOutlet。 另请注意,该属性具有 retain 修饰符,这意味着您有责任在不再需要该对象时释放它。

【讨论】:

  • 如果您发现您仍然收到此消息但您的界面中有一个@property,请尝试执行 Product > Clean。
猜你喜欢
  • 2012-08-20
  • 1970-01-01
  • 2013-10-08
  • 2012-02-01
  • 2012-01-23
  • 1970-01-01
  • 2021-11-28
  • 1970-01-01
相关资源
最近更新 更多