问题
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