未找到ios类“预期类型” [英] ios class not found "Expected a type"

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

问题描述

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



FooterSelectorView.h

  #import< UIKit / UIKit.h> 
#importFooterArchiveItemView.h

@interface FooterSelectorView:UIImageView

// #warning属性类型'activeItem'与访问者类型'setActiveItem不匹配:'
@property(nonatomic,retain)FooterArchiveItemView * activeItem;

// #error期望类型
- (void)setActiveItem:(FooterArchiveItemView *)activeItem_;
- (void)update;
- (CGPoint)absoluteCenterOf:(UIView *)obj;

@end

相关课程



FooterArchiveItemView.h

  #import< ; UIKit的/ UIKit.h> 
#importAutosizeableView.h
#importFooterArchiveView.h

typedef void(^ DayBlock)(void);

@interface FooterArchiveItemView:AutosizeableView {
DayBlock dayBlock;
}

@property(非原子,保留)IBOutlet UIButton * day;
@property(非原子,保留)IBOutlet UIImageView * bullet;

- (void)setDayBlock:(DayBlock)块;

@end

AutosizeableView.h

  #import< UIKit / UIKit.h> 

@interface AutosizeableView:UIView

@end


解决方案

我建议的一件事是你遵守Obj-C实践,在头文件接口文件中,而不是导入自定义类,你可以向前声明它们。例如,在FooterSelectorView.h中,而不是:

  #importFooterArchiveItemView.h

向前宣布班级:

  @class FooterArchiveItemView 

然后,在实现文件(FooterSelectorView.m)中导入。在这种情况下观察实践可能实际上并没有解决你的问题(我不知道究竟发生了什么,我个人想看到更多的代码来冒险猜测),但它可能有助于为你隔离问题。 / p>

此规则的注意事项是Apple的框架 - 这些框架被导入标题。


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

解决方案

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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆