11684
11684

Reputation: 7507

Protocol not working

It's a pretty stupid mistake, I'm sure, but I can't find it.
What I've found is mostly that one has forgotten an #import line.
I did not. I'm very new to objective-c, and tried protocols, but I got 8 errors now...
I'm pretty sure it is the protocol, because there are 2 errors in my protocol, and all other errors say 'can't find protocol definition' what I thought was caused by the errors in the protocol.
Here's the code:

#import <UIKit/UIKit.h>
#import "CongTile.h"


@protocol TileDelegate

- (UIColor *)colorForTile:(CongTile *)tile; // Expected ')' before 'CongTile'
- (BOOL) drawArmyOnTile:(CongTile *)tile; // same error

@end

Upvotes: 1

Views: 186

Answers (1)

Paul.s
Paul.s

Reputation: 38728

Try losing the #import "CongTile.h" in favour of @class CongTile;

If you use #import and both file's end up importing each other you create an import loop.


Side note

Assuming that any class that implements TileDelegate will be a descendant of NSObject you may wish to declare your protocol as

@protocol TileDelegate <NSObject>

this way the compiler knows that any time you use id<TileDelegate> delegate in your code the object will respond to <NSObject>

Upvotes: 4

Related Questions