Re: pragma nowarn
Re: pragma nowarn
- Subject: Re: pragma nowarn
- From: Alastair Houghton <email@hidden>
- Date: Wed, 12 Dec 2007 13:14:55 +0000
On 12 Dec 2007, at 13:03, Alexander v. Below wrote:
On 12.12.2007, at 13:47, Alastair Houghton wrote:
I have yet to see a situation where there is genuinely a reason for
not changing the code to fix a warning, assuming that you don't
enable any of the sillier warning flags.
Especially when you want to dynamically call methods from different
SDKs, getting rid of the warnings can be a challenge. Example:
Take this code, which is compiled against the 10.2 SDK (but the
issue is the same for any cross-SDK development):
if (floor(NSAppKitVersionNumber) > 663) // NSAppKitVersionNumber10_2
[center postNotificationName:myNotification object:nil
userInfo:info options:(1 << 1)];
else
[center postNotificationName:myNotification object:nil
userInfo:info];
This will produce the following warning:
warning: `NSDistributedNotificationCenter' may not respond to `-
postNotificationName:object:userInfo:options:'
warning: cannot find method `-
postNotificationName:object:userInfo:options:'; return type `id'
assumed
For someone who likes his code warning free, I have found no way of
getting rid of this warning. And I DO NOT want to turn off the
"cannot find method" warning
So build against the 10.3 SDK (or the 10.4 or 10.5 SDKs) instead,
setting the "Mac OS X Deployment Target" build setting to 10.2. Then
the method will have been declared by the framework headers.
(There are hackier solutions, for instance declaring the method
yourself e.g. on a category of NSNotificationCenter. But the
officially supported one is using the newer SDK and the deployment
target setting.)
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden