本文介绍了未找到 ios 类“预期类型"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 FooterSelectorView.h 中有两个问题,我不知道为什么.一个是警告,另一个是错误.由于某种原因,xcode 无法识别 FooterArchiveItemView 所以我无法将我的对象键入为导致其他问题的对象.有没有人见过这样的东西?我该如何解决?

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

相关类

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

推荐答案

我建议您遵守 Obj-C 实践,即在头接口文件中,而不是导入自定义类,您转发-声明它们.例如,在 FooterSelectorView.h 中,而不是:

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"

前向声明类:

@class FooterArchiveItemView

然后,在实现文件 (FooterSelectorView.m) 中导入.在这种情况下,观察实践可能无法真正解决您的问题(我不知道到底发生了什么,我个人希望看到更多代码来冒险猜测),但它可能有助于为您隔离问题.

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.

值得注意的例外是 Apple 的框架——它们被导入到标头中.

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

这篇关于未找到 ios 类“预期类型"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-24 09:27