ios class not found “Expected a type”

让人想犯罪 __ 提交于 2019-11-28 10:11:08

问题


I'm getting two problems in my FooterSelectorView.h and I have no idea why. One is a warning while the other is an error. For some reason xcode doesn't recognize FooterArchiveItemView so I'm not able to type my object as that which is causing other propblems. Has anyone ever seen anything like this before? How can I fix it?

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

Related Classes

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

回答1:


One thing I'd suggest is that you conform to the Obj-C practice, that, within header interface files, rather than importing custom classes, you forward-declare them. For example, in FooterSelectorView.h, rather than:

#import "FooterArchiveItemView.h"

Forward-declare the class:

@class FooterArchiveItemView

Then, in the implementation file (FooterSelectorView.m), you import. Observing the practice may not actually solve your issue in this case (I don't know exactly what's happening, personally I'd want to see a bit more code to hazard a guess), but it might help isolate the issue for you.

The noted exception to this rule is Apple's frameworks - those are imported into headers.



来源:https://stackoverflow.com/questions/9607489/ios-class-not-found-expected-a-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!