导入协议时没有类型或协议错误 [英] No type or protocol error while protocol is imported

查看:115
本文介绍了导入协议时没有类型或协议错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,在 LoadingVC.h 中我声明了一个协议:

At first, in LoadingVC.h I declare a protocol:

@protocol VideoWorker <NSObject>

@required

@property (nonatomic) float progress;
@property (nonatomic) BOOL done;

-(void)beginWorking;

@end

@interface LoadingVC : UIViewController <UIAlertViewDelegate>
...
@end

然后在 BlurWorkerGPU.h 中

then in BlurWorkerGPU.h

...
#import "LoadingVC.h"

@interface BlurWorkerGPU  : NSObject <VideoWorker> {
...
}
- (void)beginWorking;
@property(nonatomic)float progress;
@property(nonatomic)BOOL done;
 ...
@end

然而,llvm 说

没有名为‘VideoWorker’的类型或协议"

"No type or protocol named 'VideoWorker'"

这很奇怪,因为我正在导入定义协议的标头.有什么线索吗?

which is strange since I am importing the header where the protocol is defined. Any clues?

推荐答案

在使用之前,您应该在 .h 文件中转发声明协议.把它放在 BlurWorkerGPU.h

You should forward declare protocol in .h files before you use it. Put this in the top of BlurWorkerGPU.h

@protocol VideoWorker;

这篇关于导入协议时没有类型或协议错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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