开发者

Why doesn't XCode realise that I've synthesised my property?

In my interface, I have:

#开发者_JAVA技巧import <UIKit/UIKit.h>

@protocol AddCategoryDelegate;

@interface AddCategoryViewController : UIViewController {
    id <AddCategoryDelegate> _delegate; 
}

@property (nonatomic, assign, readwrite) id <AddCategoryDelegate> delegate;    
@property (nonatomic, retain) IBOutlet UITextField *textField;
@property (nonatomic, retain) IBOutlet UILabel *textLabel;    
- (IBAction)saveAction:(id)sender;

@end



@protocol AddCategoryDelegate <NSObject>

- (void)addCategoryViewController:(AddCategoryViewController *)addCategoryViewController didAddCategory:category;

@end

And in my implementation, I have:

#import "AddCategoryViewController.h"

@implementation AddCategoryViewController

@synthesize delegate = _delegate;
@synthesize textField;
@synthesize textLabel;

// methods

@end

But I keep getting the following warnings from XCode:

Property 'textLabel' requires the method 'setTextLabel:' to be defined - use @synthesize, @dynamic or provide a method implementation.

Property 'textLabel' requires the method '-textLabel' to be defined - use @synthesize, @dynamic or provide a method implementation.

Is this an XCode 4 bug, or am I doing something wrong?


Worth noting: copying the above code doesn't result in the warning on my installation. Can you make sure there isn't a typo in the real code?

Otherwise, you could try removing the IBOutlet keyword from the variable declaration, and only keep it on the property declaration. That might be confusing things...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜