开发者

Incompatible pointer types assigning to 'NSHTTPURLResponse *' from 'NSURLResponse *'

开发者 https://www.devze.com 2023-03-27 12:23 出处:网络
I get the warning Incompatible pointer types assigning to \'NSHTTPURLResponse *\' from \'NSURLResponse *\' in the code below. This method is part of Sharekit.

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:(开发者_如何学GoNSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)aResponse
{
    if (response)
        [response release];
    ***response = [aResponse retain];***
    [responseData setLength:0];
}

Someone please help!

Thanks!


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];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号