Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No type or protocol named 'ReformerProtocol' in .h, but .m works fine

Tags:

ios

swift

I have a protocol in swift:

import Foundation

@objc protocol ReformerProtocol {
    func reformDataWithManager(apiManager: FSAPIClient) -> NSDictionary
}

In my Objective C .m if i define a method like:

- (NSDictionary *)fetchDataWithReformer:(id<ReformerProtocol>)reformer {
}

it works fine, but if i declare this method in .h file:

- (NSDictionary *)fetchDataWithReformer:(id<ReformerProtocol>)reformer;

The error is:

No type or protocol named 'ReformerProtocol' 

Not sure the reason.

like image 324
William Hu Avatar asked Sep 24 '15 02:09

William Hu


1 Answers

You should simply forward-declare the protocol in the .h file before using it.

@protocol ReformerProtocol;
like image 66
jtbandes Avatar answered Oct 01 '22 04:10

jtbandes