我很快就有了一个协议(protocol):
import Foundation
@objc protocol ReformerProtocol {
func reformDataWithManager(apiManager: FSAPIClient) -> NSDictionary
}
在我的 objective-c .m中,如果我定义一个方法,例如:
- (NSDictionary *)fetchDataWithReformer:(id<ReformerProtocol>)reformer {
}
它工作正常,但是如果我在.h文件中声明此方法:
- (NSDictionary *)fetchDataWithReformer:(id<ReformerProtocol>)reformer;
错误是:
No type or protocol named 'ReformerProtocol'
不知道原因。
最佳答案
您应该在使用前先在.h文件中向前声明协议(protocol)。
@protocol ReformerProtocol;