Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ObjectiveC Syntax for Specifying Protocol Name in Method Argument

Tags:

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'

like image 365
live2dream95 Avatar asked Apr 20 '10 14:04

live2dream95


1 Answers

Try:

- (void) register:(NSObject<MyProtocol>*) cb; 
like image 118
Vladimir Avatar answered Sep 22 '22 15:09

Vladimir