ios class not found quot;Expected a typequot;(未找到 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 类“预期类型"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:未找到 ios 类“预期类型"
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
