Re: CodeWarrior and Objective-C warnings
Re: CodeWarrior and Objective-C warnings
- Subject: Re: CodeWarrior and Objective-C warnings
- From: John Stiles <email@hidden>
- Date: Wed, 1 Dec 2004 17:22:04 -0800
FWIW, "the web agrees with me" is a weak argument if the web is wrong :) The first one seems fine to me, but the second one will completely break if Apple ever decided to return a subclass of NSHTTPURLResponse, and that would be a legitimate change to AppKit AFAICS. (Hmm, legitimate variations off the top of my head... NSSecureHTTPURLResponse? NSCachedHTTPURLResponse? NSProxyHTTPURLRequest?)
On Dec 1, 2004, at 5:05 PM, Jeff Laing wrote:
Ok, the web agrees with me ...
http://www.cocoabuilder.com/archive/message/cocoa/2004/9/13/117211
http://cocoa.mamasam.com/COCOADEV/2004/02/1/83778.php
...for what thats worth :-)
-----Original Message-----
From: Jeff Laing
Sent: Thursday, December 02, 2004 12:02 PM
To: 'John Stiles'
Cc: email@hidden
Subject: RE: CodeWarrior and Objective-C warnings
I think I'd be testing for that class and casting, rather than testing that that message was processed. After all, someone may introduce a different NSURLResponse subclass that responds to that message in a different way, or at least in a way you weren't expecting...
-----Original Message-----
From: John Stiles [mailto:email@hidden]
Sent: Thursday, December 02, 2004 11:56 AM
To: Jeff Laing
Cc: email@hidden
Subject: Re: CodeWarrior and Objective-C warnings
"statusCode" isn't mine, it's a NSHTTPURLResponse selector. The NSURLResponse being sent to the callback is actually an NSHTTPURLResponse--at least, that's the plan :)
On Dec 1, 2004, at 4:52 PM, Jeff Laing wrote:
My guess would be to make your statusCode part of a formal protocol and then use an explicit cast once you are sure that response implements the protocol.
Alternately, if you are going to use respondsToSelector: to test viability, you could use performSelector: to actually invoke it.
-----Original Message-----
From: John Stiles [mailto:email@hidden]
Sent: Thursday, December 02, 2004 11:43 AM
To: email@hidden
Subject: CodeWarrior and Objective-C warnings
I have code that looks like this
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
if( [response respondsToSelector:@selector(statusCode)] )
{
if( [response statusCode] == 200 )
{
// stuff
}
}
}
When I call [response statusCode] in the code above, CodeWarrior warns that "receiver cannot handle this message." Obviously this was taken care of on the previous line, but I can see how a compiler might not understand this :) How can I placate the compiler and silence the warning (other than disabling warnings)?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden