分配给“NSHTTPURLResponse *”的指针类型不兼容来自“NSURLResponse *”
我在下面的代码中收到警告:不兼容的指针类型从“NSURLResponse *”分配给“NSHTTPURLResponse *”。此方法是 Sharekit 的一部分。
带有警告的行是粗体/斜体的:
- (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)aResponse
{
if (response)
[response release];
***response = [aResponse retain];***
[responseData setLength:0];
}
有人请帮忙!
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于编译器来说,
aResponse
和[aResponse keep]
的结果是一个 NSURLResponse。不过我猜测response
是一个 NSHTTPURLResponse。由于 NSURLResponse 是 NSHTTPURLResponse 的超类,因此您不能直接分配 - 但您可以使用强制转换来删除警告:To the compiler,
aResponse
, and the result of[aResponse retain]
, is an NSURLResponse. However I'm guessingresponse
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: