如何检查NSDATA类型?
我有下载图像的类
首先我有 NSMutable
URLRequest
比我建立 NSURLConnection
并且我想检查我在此函数中收到的数据
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
如果是图像,则写入文件夹;如果是文本,则跳到下一张图像。
如何检查接收到的数据类型?
I have the class which downloads images
First I have NSMutable
URLRequest
than I establish NSURLConnection
and than I want to check which data I received in this function
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
If it is image than write to the folder when it is some text than skip to the next image.
How do I check the type of received data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 NSURLConnection 的委托方法中,您可以获取响应头,从中您可以获取内容类型。如果服务器内容类型设置正确,您将在此处正确获得响应的内容类型。
In delegate method of NSURLConnection, you can get header of response, from which you can get content type. If content type is set correctly from server, you will get content type in response over here correctly.