Alex Rivera | Logout

ObjectiveC Syntax for Specifying Protocol Name in Method Argument

Asked 2010-04-20T14:47:49.610
21

What's the ObjectiveC syntax for specifying a protocol as an argument in a method?

Say I have 2 protocols, MyProtocol and MyProtocolCB:

@protocol MyProtocolCB <NSObject>
- (void) func;
@end

@protocol MyProtocol <NSObject>
- (void) register:(MyProtocolCB*) cb;
@end

I'm receiving this syntax error: error: expected type-specifier before 'MyProtocolCB'

Edit
Report

1 Answer

51

Try:

- (void) register:(NSObject<MyProtocol>*) cb;
answered 2010-04-20T14:53:42.507

Your Answer