2
我在FooterSelectorView.h
中遇到了两个问题,我不知道为什么。一个是警告,另一个是错误。出于某种原因,xcode不能识别FooterArchiveItemView
,所以我不能将我的对象键入为导致其他propblems的那个对象。有没有人见过这样的事情?我该如何解决它?未找到ios类“预期类型”
FooterSelectorView.h
#import <UIKit/UIKit.h>
#import "FooterArchiveItemView.h"
@interface FooterSelectorView : UIImageView
// #warning Type of property 'activeItem' does not match type of accessor 'setActiveItem:'
@property (nonatomic, retain) FooterArchiveItemView *activeItem;
// #error Expected a type
- (void)setActiveItem:(FooterArchiveItemView *)activeItem_;
- (void)update;
- (CGPoint)absoluteCenterOf:(UIView *)obj;
@end
相关类
FooterArchiveItemView.h
#import <UIKit/UIKit.h>
#import "AutosizeableView.h"
#import "FooterArchiveView.h"
typedef void (^ DayBlock)(void);
@interface FooterArchiveItemView : AutosizeableView {
DayBlock dayBlock;
}
@property (nonatomic, retain) IBOutlet UIButton *day;
@property (nonatomic, retain) IBOutlet UIImageView *bullet;
- (void)setDayBlock:(DayBlock)block;
@end
AutosizeableView.h
#import <UIKit/UIKit.h>
@interface AutosizeableView : UIView
@end
我试过这个没有成功,然后我只是到处去添加这个到很多类,而且什么也没有。然而,然后我评论了所有的类声明,它的工作。很奇怪...... - 这只是一个最佳实践或什么? – Jacksonkr 2012-03-07 19:32:14
很高兴它有你的地方,这里有几个很好的解释:http://stackoverflow.com/questions/322597/class-vs-import – isaac 2012-03-07 19:48:57
转发声明比头文件中的导入安全得多,除非你安全地构造你的头文件以这种方式循环引用不会引起任何问题(标题A导入类B并且标题B导入类A)。我认为这是通过前向声明来解决的,头文件(在.m文件中导入)不会自行导入,这意味着它们不会陷入循环。 – Warkst 2013-02-01 22:59:57