Compiler error - method not found on object which conforms to protocol


Sandor Szatmari
 

I have a server class which is abstracted to receive it’s final configuration from it’s data source. The idea is you instantiate the server set the data source and then start the server. During startup the server reads some configuration, such as the port to start on, from the data source. This is outlined in pseudocode below. This is mostly working except for a compiler error I can’t explain. The compiler issues an error about accessing the port from the data source.

Port = self.dataSource.serverPort;

It says “Property ‘-serverPort’ not found on object of type ‘id<dataSrcProto>’”

Anyone come across this?

——— server.h/m ———-
@class server
@property (readwrite,assign) id<dataSrcProto> dataSource
-(void)start
{
Port = self.dataSource.serverPort;
… start the server
}
@end

——— dataSource.h/m ———-
@class dataSource <dataSrcProto>
-(NSUinteger)serverPort{return 8080;}
@end

——— dataSrcProto.h ———-
@protocol dataSrcProto
-(NSUinteger)serverPort;
@end

Sandor

Join cocoa@apple-dev.groups.io to automatically receive all group messages.