目标C:“属性实现必须在接口中具有其声明". [英] Objective C: "Property implementation must have its declaration in interface"

查看:363
本文介绍了目标C:“属性实现必须在接口中具有其声明".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

//RootViewController.h:

//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

//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的新手.

I'm using XCode 4.1 and was wondering if someone could please help me get to the bottom of this error. I'm very new to XCode.

在此先感谢

推荐答案

您需要在接口中使用@property声明属性.

You need to declare the property with @property in your interface.

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

在这里,使用非原子的是因为它是IBOutlet. 还要注意,该属性具有keep修饰符,这意味着您有责任在不再需要该对象时将其释放.

Here, non-atomic is used because it's an IBOutlet. Also note the property has the retain modifier, meaning you are responsible to release the object when you don't need it anymore.

这篇关于目标C:“属性实现必须在接口中具有其声明".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆