objective-c - 数据 = [NSData dataWithContentsOfURL :theUrl];

标签 objective-c nsurlconnection nsdata http-status-code-400

如果发生 4xx 或 5xx 错误,数据对象会发生什么情况? 程序会崩溃吗?数据对象是否获取任何类型的数据(响应错误或损坏的数据)?或者数据对象将等于nil?

最佳答案

您将得到nil。如果您想知道失败的原因,请使用:

[NSData dataWithContentsOfURL:options:error:]

( reference )

关于objective-c - 数据 = [NSData dataWithContentsOfURL :theUrl];,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13358271/

相关文章:

ios - xcode iOS 每次检查 url 前缀

iphone - 超越 UIView 的交互

ios - UIWebView 中的进度条

ios - 在UIWebView中加载mp3

ios - 如何将 UIImage 或 NSData 转换为字节数组并发布到服务器?

objective-c - cell.image 已弃用

iphone - 检测动画的完成

core-data - 保存 [UIColor colorWithPatternImage :image] UIColor to Core Data using NSKeyedArchiver

具有单独线程的 NSURLConnection 委托(delegate)

macos - Mac Cocoa 应用程序中的 NSURLConnection 有连接限制吗?