且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查 NSDATA 类型?

更新时间:2023-11-29 14:25:28

在 NSURLConnection 的 delegate 方法中,可以获得响应的头部,从中可以获得内容类型.如果从服务器正确设置了内容类型,您将在此处正确获得响应的内容类型.

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];
}