I just upgraded to Xcode version 4.3.2 (4E2002). I'm converting a mock class from manual memory management to ARC.
The code looks like this:
@implementation OCProtocolMockObject
- (id)initWithProtocol:(Protocol *)aProtocol
{
[super init];
mockedProtocol = aProtocol;
return self;
}
- (NSString *)description
{
return [NSString stringWithFormat:@"OCMockObject[%s]", [mockedProtocol name]];
}
The @interface looks like this:
@interface OCProtocolMockObject : OCMockObject
{
Protocol *mockedProtocol;
}
The compiler complains that:
"Receiver type 'Protocol' for instance message is a forward declaration".
"mockedProtocol" is highlighted in the description method.
I've run into this problem before. In ARC mode, usually its because the compiler is stricter about forward references, and you just need to include the appropriate header file.
However, the only "Protocol.h" I can find is
#import <objc/Protocol.h>
Importing this does nothing. Also, adding the import to OCProtocolMockObject.h does nothing. Is there some other Protocol.h I'm not aware of?