I’m trying to force all implementers of a protocol to implement a readonly property. This is my attempt:
@protocol Foo
@property(readonly) BOOL isPending;
@end
@interface Bar <Foo>
@end
@implementation Bar
- (BOOL) isPending {
return NO;
}
@end
Why am I getting a warning in in the protocol file?
Property ‘isPending’ requires method ‘isPending’ to be defined
It’s a protocol! Protocols are not supposed to implement the functions! The classes who implement the protocol should implement the functions, which is exactly what I did.
I’m unable to reproduce the problem you’re reporting under Xcode 4.3.2. Is it possible you’ve declared something to implement
Foobut neglected to add a getter to it forisPending? A diagnostic might be to add- (BOOL) isPendingto the protocol in place of the@propertyand see if there’s any difference. You can still use dot syntax even with fully declared getters and setters so it shouldn’t make a syntactic difference to any other part of your program.