我的.h文件中有如下代码
@interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {
NSArray *activities;
NSArray *feelings;
}在我的.m文件中,我使用了@synthesize属性
#import "tweetViewController.h"
@synthesize activites,feelings;但它显示了错误信息...
发布于 2011-08-11 18:42:28
你需要把它放在一个实现中。
将@synthesize ...行替换为以下内容:
@implementation tweetViewController
@synthesize activities, feelings;
@end您还需要为此声明@property,并以正确的方式关闭@interface:
替换以下行:
@interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {
NSArray *activities;
NSArray *feelings;
}有了这个:
@interface tweetViewController : UIViewController<UIPickerViewDataSource , UIPickerViewDelegate>
@property (nonatomic, retain) NSArray *activities;
@property (nonatomic, retain) NSArray *feelings;
@end发布于 2011-08-11 18:45:12
在花括号{}中声明的变量称为ivars或instance variables。实际上,您应该像这样声明属性。
@property (nonatomic, retain) NSArray *activities;所以你的代码看起来像这样,
@interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {
NSArray *activities; // ivar
NSArray *feelings; // ivar
}
@property (nonatomic, retain) NSArray *activities; // property
@property (nonatomic, retain) NSArray *feelings; // property发布于 2011-08-11 18:47:43
@interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {
NSArray *activities;
NSArray *feelings;
}
@property(nonatomic,retain) NSArray *activities;
@property(nonatomic,retain) NSArray *feelings;
@end您应该首先声明属性。试试这段代码。
https://stackoverflow.com/questions/7024441
复制相似问题