How to check the NSDATA type?

泪湿孤枕 提交于 2019-12-11 04:46:48

问题


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?


回答1:


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.

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
       NSDictionary *dicFields = [response allHeaderFields];
}


来源:https://stackoverflow.com/questions/6507070/how-to-check-the-nsdata-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!