[cfe-dev] Objective-C: Protocol method implemented in class is not recognised by category conforming to protocol
Fariborz Jahanian
fjahanian at apple.com
Tue Apr 3 18:05:07 PDT 2012
On Apr 3, 2012, at 6:00 PM, Aidan Steele wrote:
> Hi all,
>
> Sorry for the mouthful of a subject line, but I wanted it to be
> descriptive. :) I have the following code:
>
> #import <Foundation/Foundation.h>
>
> @interface Test : NSObject
> - (id)testMethod;
> @end
>
> @implementation Test
>
> - (id)testMethod;
> {
> return nil;
> }
>
> @end
>
> @protocol TestProtocol <NSObject>
> - (id)testMethod;
> - (id)secondMethod;
> @end
>
> @interface Test (TestCategory) <TestProtocol>
> @end
>
> @implementation Test (TestCategory)
>
> - (id)secondMethod;
> {
> return nil;
> }
>
> @end
>
> It generates the following warnings:
>
>
> $ clang test.m
> test.m:24:17: warning: incomplete implementation [-Wincomplete-implementation]
> @implementation Test (TestCategory)
> ^
> test.m:24:17: warning: method in protocol not implemented [-Wprotocol]
> test.m:17:1: note: method declared here
> - (id)testMethod;
> ^
> test.m:21:12: note: required for direct or indirect protocol 'TestProtocol'
> @interface Test (TestCategory) <TestProtocol>
> ^
> 2 warnings generated
>
>
> As you can see, the method declared in the protocol is defined in the
> original class implementation and not the category that declares its
> conformance to the protocol. I can't re-define the method in the
> category and call through to "super" as that would go through to
> NSObject.
>
> My question is this: is this (a) a bug in clang, (b) a bug in my
> understanding or (c) a combination of the above?
(d) bug has already been fixed in TOT.
- fariborz
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list