Question

I get the warning Incompatible pointer types assigning to 'NSHTTPURLResponse *' from 'NSURLResponse *' in the code below. This method is part of Sharekit.

The line with the warning is the bolded/italicized one:

    - (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)aResponse
{
    if (response)
        [response release];
    ***response = [aResponse retain];***
    [responseData setLength:0];
}

Someone please help!

Thanks!

Était-ce utile?

La solution

To the compiler, aResponse, and the result of [aResponse retain], is an NSURLResponse. However I'm guessing response is an NSHTTPURLResponse. Since NSURLResponse is a superclass of NSHTTPURLResponse, you can't just assign directly — but you can use a cast to remove the warning:

response = (NSHTTPURLResponse *)[aResponse retain];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top