Re: Getting rid of warning in Xcode
Re: Getting rid of warning in Xcode
- Subject: Re: Getting rid of warning in Xcode
- From: Laurent Daudelin <email@hidden>
- Date: Sat, 13 Dec 2003 00:13:44 -0500
on 12/12/03 22:50, Mark Munz at email@hidden wrote:
> I'm writing some code that uses a new 10.3 API only if it's found (ie.
> respondsToSelector: and only sends the message if it does respond).
>
> The problem I have is that Xcode always warns me on each one of these.
> Is there some technique to get rid of the warning for the cases that I
> know aren't correct?
>
> NSButton* btn;
>
> {btn gets setup}
>
> if ([btn respondsToSelector:@selector(setHidden:)])
> {
> [btn setHidden:YES]; <-- ALWAYS get a warning
> }
>
> Any help with this would be great.
>
You're still getting the warning because the SDK you chose is probably not
10.3. I've ran into the same problem and the only way around it is to
whether use 'performSelector:withObject:' or change the SDK to 10.3. The
problem here is that the argument to the 'setHidden:' is a primitive type,
not an object, so you won't be able to use 'performSelector:withObject:'.
So, you'll have to change the SDK selected for your project to 10.3 and
then, if you want to support older versions of OS X, you'll have to run some
compatibility check after modifying your code, or track the methods you're
using very carefully so that you can verify, as in your code, whether the
object responds to that message or not.
What I usually do after making some substantial changes is the inclusion of
a header file that declares the following:
#import <Foundation/NSObject.h>
#include <AvailabilityMacros.h>
#ifdef MAC_OS_X_VERSION_MAX_ALLOWED
#undef MAC_OS_X_VERSION_MAX_ALLOWED
#endif
#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_2
Then, in the active build style, I add this header to the "Prefix Header"
setting (you can find it in the "GNU C/C++ Compiler"). Then, clean and
recompile. The header file will be included in all your source and every
method that you use that is defined for 10.3 will be flagged and you'll get
a warning. You just have to review each warning to see if it applies to your
code. This is because, depending on the imports you have, some might trigger
a warning because a header in 10.3 is referencing a method or a type of some
sort that was also introduced in 10.3. If the warning is not directly
generated from your code, you can safely ignore those warnings, or, in the
compatibility header you use, you can fake the declaration of those symbols.
Like, in any of my class, when I do import AppKit.h, I get a warning about
'NSAnimationEffect' not being defined but referenced from a multitude of
AppKit header files. So, I did a declaration of this type just to keep the
compiler happy. I'm not using any kind of animation effect in my program, so
I'm pretty safe.
-Laurent.
--
============================================================================
Laurent Daudelin AIM/iChat: LaurentDaudelin <http://nemesys.dyndns.org>
Logiciels Nemesys Software mailto:email@hidden
fish n.: [Adelaide University, Australia] 1. Another metasyntactic variable.
See foo. Derived originally from the Monty Python skit in the middle of "The
Meaning of Life" entitled "Find the Fish". 2. A pun for `microfiche'. A
microfiche file cabinet may be referred to as a `fish tank'.
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.