如何改进创建受保护属性的尝试

时间:2013-03-20 11:28:33

标签: objective-c xcode4.5

#import "BGReviewController.h"

@interface BGReviewController (protected)
@property (weak, nonatomic) IBOutlet UIImageView *backgroundImage;
@property (weak, nonatomic) IBOutlet UIButton *dislikeButton;
@property (weak, nonatomic) IBOutlet UIButton *likeButton;
@property (weak, nonatomic) IBOutlet UIButton *post;
@property (weak, nonatomic) IBOutlet UIButton *cancel;
@property (weak, nonatomic) IBOutlet UITextView *textView;
@end

然后我补充说:

@synthesize backgroundImage = _backgroundImage;
@synthesize dislikeButton = _dislikeButton;
@synthesize likeButton = _likeButton;
@synthesize post = _post;
@synthesize cancel = _cancel;
@synthesize textView = _textView;

我得到了错误: /business/Dropbox/badgers/BadgerNew/BGReviewController.m:32:13:在类实现中声明的属性'protected'无法在类实现中实现

我应该在类别的实现文件中声明合成,然后明确地放入ivars吗?

2 个答案:

答案 0 :(得分:1)

你不能在一个类别中使用@synthesize,你必须手动执行getter和setter

check out this answer

答案 1 :(得分:1)

替换

@interface BGReviewController (protected)

使用

@interface BGReviewController ()