开发者

error:on declaring @synthesize method

开发者 https://www.devze.com 2023-03-27 01:51 出处:网络
I have code in my .h file as follows @interface tweetViewController : UIViewController<UIPickerViewDataSource ,UIPickerViewDelegate> {

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 @propertys 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消