gpt4 book ai didi

iphone - NSURLConnection didFailWithError 未调用?

转载 作者:行者123 更新时间:2023-12-03 20:57:31 24 4
gpt4 key购买 nike

为什么当指定 URL 不存在图像时,didFailWithError 不会被调用?例如:

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/images/someImageIknowDoesntExist.jpg"] 
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:10.0];

urlConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];

不触发didFailWithError。我如何收到有关我尝试连接的网址没有图像的通知?

最佳答案

当您获取connection:didReceieveResponse:方法时,响应中的状态代码将为404。仅当获取 URL 时实际发生错误(例如网络故障或主机不存在等)时,才会调用 error 方法。

关于iphone - NSURLConnection didFailWithError 未调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3982598/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com