error:on declaring @synthesize method
I have code in my .h file as follows
@interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {
NSArray *activities;
NSArray *f开发者_运维问答eelings;
}
and in my .m file i used @synthesize property
#import "tweetViewController.h"
@synthesize activites,feelings;
but it shows me error message....
You need to put it in an implementation.
Replace the @synthesize ...
line with this:
@implementation tweetViewController
@synthesize activities, feelings;
@end
You also need to declare @property
s for this, and close the @interface
the correct way:
Replace the following lines:
@interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {
NSArray *activities;
NSArray *feelings;
}
With this:
@interface tweetViewController : UIViewController<UIPickerViewDataSource , UIPickerViewDelegate>
@property (nonatomic, retain) NSArray *activities;
@property (nonatomic, retain) NSArray *feelings;
@end
Variables declared inside the braces {}
are called ivars
orinstance variables
. Actually you should declare properties like this.
@property (nonatomic, retain) NSArray *activities;
So your code looks like this,
@interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {
NSArray *activities; // ivar
NSArray *feelings; // ivar
}
@property (nonatomic, retain) NSArray *activities; // property
@property (nonatomic, retain) NSArray *feelings; // property
@interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {
NSArray *activities;
NSArray *feelings;
}
@property(nonatomic,retain) NSArray *activities;
@property(nonatomic,retain) NSArray *feelings;
@end
you should first declare property. Try this code.
精彩评论