• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CodeWarrior and Objective-C warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CodeWarrior and Objective-C warnings


  • Subject: Re: CodeWarrior and Objective-C warnings
  • From: Sherm Pendley <email@hidden>
  • Date: Wed, 1 Dec 2004 21:14:09 -0500

On Dec 1, 2004, at 7:42 PM, John Stiles wrote:

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)?

You could use NSInvocation instead of a direct message:

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSInvocation *anInvocation;
NSMethodSignature *aSig;
int statusCode; // I didn't look this up - declare the type as needed


	if( [response respondsToSelector:@selector(statusCode)] )
	{
		aSig = [response methodSignatureForSelector: @selector(statusCode)];
		anInvocation = [NSInvocation invocationWithMethodSignature: aSig];

		[anInvocation invokeWithTarget: response];
		[anInvocation getReturnValue: &statusCode];

		if( statusCode == 200 )
		{
			// stuff
		}
	}
}

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org

_______________________________________________
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


References: 
 >CodeWarrior and Objective-C warnings (From: John Stiles <email@hidden>)

  • Prev by Date: Re: cross development on Jaguar
  • Next by Date: RE: Swapping isa's (was Re: Hex Edit controls (resknife))
  • Previous by thread: Re: CodeWarrior and Objective-C warnings
  • Next by thread: Re: CodeWarrior and Objective-C warnings
  • Index(es):
    • Date
    • Thread