disable warning for override in category?
-
Hi All,
I need to override a method in a category. I know I'm not supposed to do it but and I don't except in one place which is legacy code and I need it to keep working. Yesterday, everything was working fine. This morning, I upgraded to Xcode 4.3 and now I'm getting more warnings (warnings == errors) including
category is implementing a method which will also be implemented by its primary class [-Werror,-Wobjc-protocol-method-implementation]
I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is. I really do not want to turn off warnings == errors but that's what I have to do for now.
Can anyone help?
Thanks a lot
Marc -
On 16.02.2012, at 17:12, Marc Respass wrote:
> Hi All,
>
> I need to override a method in a category. I know I'm not supposed to do it but and I don't except in one place which is legacy code and I need it to keep working. Yesterday, everything was working fine. This morning, I upgraded to Xcode 4.3 and now I'm getting more warnings (warnings == errors) including
>
> category is implementing a method which will also be implemented by its primary class [-Werror,-Wobjc-protocol-method-implementation]
>
> I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is. I really do not want to turn off warnings == errors but that's what I have to do for now.
have you tried using #pragma? http://clang.llvm.org/docs/UsersManual.html#diagnostics_pragmas
According to the documentation
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
// do your override
#pragma clang diagnostic pop
should work
Cheers,
Felix
>
> Can anyone help?
>
> Thanks a lot
> Marc
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (<Xcode-users...>)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/xcode-users/<franz...>
>
> This email sent to <franz...>
-
El feb 16, 2012, a las 12:28 p.m., Felix Franz escribió:
> On 16.02.2012, at 17:12, Marc Respass wrote:
>
>> Hi All,
>>
>> I need to override a method in a category. I know I'm not supposed to do it but and I don't except in one place which is legacy code and I need it to keep working. Yesterday, everything was working fine. This morning, I upgraded to Xcode 4.3 and now I'm getting more warnings (warnings == errors) including
>>
>> category is implementing a method which will also be implemented by its primary class [-Werror,-Wobjc-protocol-method-implementation]
>>
>> I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is. I really do not want to turn off warnings == errors but that's what I have to do for now.
>
> have you tried using #pragma? http://clang.llvm.org/docs/UsersManual.html#diagnostics_pragmas
>
> According to the documentation
>
> #pragma clang diagnostic push
> #pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
>
> // do your override
>
> #pragma clang diagnostic pop
> should work
That worked! I did not know about that. Thank you so much.
Marc -
On Feb 16, 2012, at 8:12 AM, Marc Respass wrote:
> I need to override a method in a category. I know I'm not supposed to do it but and I don't except in one place which is legacy code and I need it to keep working. Yesterday, everything was working fine. This morning, I upgraded to Xcode 4.3 and now I'm getting more warnings (warnings == errors) including
Wow, does that even work? I guess it’s not really a traditional OOP override, rather an overwrite, where the category method just replaces the original one entirely. I’ll take your word for it that you need this; it sounds dangerous :o
> category is implementing a method which will also be implemented by its primary class [-Werror,-Wobjc-protocol-method-implementation]
>
> I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is.
That _is_ the compiler flag :)
To disable it, you’d add the opposite flag, which I believe would be -Wno-objc-protocol-method-implementation. You can set it for just that source file by going into the Build Stages tab for that target, opening up the list of source files, and double-clicking near the right edge of the list item for that file.
—Jens -
El feb 16, 2012, a las 12:55 p.m., Jens Alfke escribió:
>
> On Feb 16, 2012, at 8:12 AM, Marc Respass wrote:
>
>> I need to override a method in a category. I know I'm not supposed to do it but and I don't except in one place which is legacy code and I need it to keep working. Yesterday, everything was working fine. This morning, I upgraded to Xcode 4.3 and now I'm getting more warnings (warnings == errors) including
>
>
> Wow, does that even work? I guess it’s not really a traditional OOP override, rather an overwrite, where the category method just replaces the original one entirely. I’ll take your word for it that you need this; it sounds dangerous :o
It did work! I agree that it is dangerous and it violates our policy which includes deprecations are warnings and warnings == errors. But I need it for this one case. It's on NSComboBoxCell and makes autocomplete case insensitive. There may be a better way to do that without subclassing but this is a few years old now so I just wanted to keep everything working.
>> category is implementing a method which will also be implemented by its primary class [-Werror,-Wobjc-protocol-method-implementation]
>>
>> I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is.
>
> That _is_ the compiler flag :)
Yea :)
> To disable it, you’d add the opposite flag, which I believe would be -Wno-objc-protocol-method-implementation. You can set it for just that source file by going into the Build Stages tab for that target, opening up the list of source files, and double-clicking near the right edge of the list item for that file.
Ah! Many thanks. Is there some place where I can find those compiler flags? I looked on Bing, Google, Apple's Dev site, and Xcode docs within Xcode 4.3 and came up empty every time. I wasn't sure what to search for. I tried "Wobjc-protocol-method-implementation" and "GCC Compiler Flags". I admit that this is not something I do a lot. I stay within Xcode checking and unchecking boxes.
I prefer the change for the file in Build Stages to the pragma so I did that and adding -Wno-objc-protocol-method-implementation also worked.
Thanks a lot everyone
Marc -
On Feb 16, 2012, at 8:12 AM, Marc Respass wrote:
> I need to override a method in a category. I know I'm not supposed to do it but and I don't except in one place which is legacy code and I need it to keep working. Yesterday, everything was working fine. This morning, I upgraded to Xcode 4.3 and now I'm getting more warnings (warnings == errors) including
>
> category is implementing a method which will also be implemented by its primary class [-Werror,-Wobjc-protocol-method-implementation]
>
> I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is. I really do not want to turn off warnings == errors but that's what I have to do for now.
-Wobjc-protocol-method-implemetation /is/ the compiler flag your looking for. Or more specifically, -Wfoo turns on a warning, -Wnofoo turns it off. You can also use a #pragma to disable warnings in particular places (which is what I would probably do for this specific warning) but I don't recall the specific syntax – you should be able to find it on llvm.org in the docs for Clang.
--
David Duncan -
El feb 16, 2012, a las 1:15 p.m., David Duncan escribió:
> On Feb 16, 2012, at 8:12 AM, Marc Respass wrote:
>
>> I need to override a method in a category. I know I'm not supposed to do it but and I don't except in one place which is legacy code and I need it to keep working. Yesterday, everything was working fine. This morning, I upgraded to Xcode 4.3 and now I'm getting more warnings (warnings == errors) including
>>
>> category is implementing a method which will also be implemented by its primary class [-Werror,-Wobjc-protocol-method-implementation]
>>
>> I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is. I really do not want to turn off warnings == errors but that's what I have to do for now.
>
> -Wobjc-protocol-method-implemetation /is/ the compiler flag your looking for. Or more specifically, -Wfoo turns on a warning, -Wnofoo turns it off. You can also use a #pragma to disable warnings in particular places (which is what I would probably do for this specific warning) but I don't recall the specific syntax – you should be able to find it on llvm.org in the docs for Clang.
Thanks David. I didn't know that either. I learned a lot today about stuff I never do and appreciate everyone's response.
Marc -
On Feb 16, 2012, at 1:15 PM, David Duncan wrote:
> On Feb 16, 2012, at 8:12 AM, Marc Respass wrote:
[snip]
>>
>> I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is. I really do not want to turn off warnings == errors but that's what I have to do for now.
>
> -Wobjc-protocol-method-implemetation /is/ the compiler flag your looking for.
Did anyone else picture Obi Wan waving his hand while reading this line?
Bill -
On Feb 16, 2012, at 7:12 PM, Bill Garrison wrote:
> On Feb 16, 2012, at 1:15 PM, David Duncan wrote:
>
>> On Feb 16, 2012, at 8:12 AM, Marc Respass wrote:
>
> [snip]
>
>>>
>>> I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is. I really do not want to turn off warnings == errors but that's what I have to do for now.
>>
>> -Wobjc-protocol-method-implemetation /is/ the compiler flag your looking for.
>
> Did anyone else picture Obi Wan waving his hand while reading this line?
Search your feelings, you know it to be true! ;-).
--
David Duncan -
On Feb 17, 2012, at 12:39 PM, David Duncan <david.duncan...> wrote:
> On Feb 16, 2012, at 7:12 PM, Bill Garrison wrote:
>
>> On Feb 16, 2012, at 1:15 PM, David Duncan wrote:
>>
>>> On Feb 16, 2012, at 8:12 AM, Marc Respass wrote:
>>
>> [snip]
>>
>>>>
>>>> I cannot find anything on -Wobjc-protocol-method-implementation anywhere. What I am hoping to do is disable the warning on just that class but I don't know what the compiler flag is. I really do not want to turn off warnings == errors but that's what I have to do for now.
>>>
>>> -Wobjc-protocol-method-implemetation /is/ the compiler flag your looking for.
>>
>> Did anyone else picture Obi Wan waving his hand while reading this line?
>
>
> Search your feelings, you know it to be true! ;-).
> --
> David Duncan
Noooooooo!


