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


Allan Odgaard
 

On 27 Mar 2021, at 2:41, Sandor Szatmari wrote:

[…] This is outlined in pseudocode below.

There is nothing conceptually wrong with what you sketch in your pseudo-code.

Please post an actual runnable example, as your pseudo-code has typos and lack context, something like the below compiles (and runs) just fine:

@protocol dataSrcProto
- (NSUInteger)serverPort;
@end

@interface MyDataSource : NSObject <dataSrcProto>
@end

@implementation MyDataSource
- (NSUInteger)serverPort { return 8000; }
@end

int main (int argc, char const* argv[])
{
    id <dataSrcProto> server; // obtained from seomewhere
    fprintf(stderr, "%ld\n", server.serverPort);
    return 0;
}

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