@protocol Eating
@end
@interface Eat : NSObject<Eating>
{
}
- (id<Eating> *)me;
@end
@implementation Eat
- (id<Eating> *)me { return self; }
@end
In the above piece of Objective-C code, why does "return self" result in a "Return from incompatible pointer type" warning? What's the incompatible pointer type and how to fix it?
Because id
is a pointer itself, you don't need the asterisk.
@interface Eat : NSObject<Eating> {
}
- (id<Eating>)me;
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With