Objective c 从NSURL获得的过滤数据
我知道如何从NSSURL获取数据,但我想问我如何过滤数据,比如页面包含文本、图像、视频等,我如何指定like仅用于提取图像。如果所有的数据都一起下载了,我怎么过滤呢Objective c 从NSURL获得的过滤数据,objective-c,ios,Objective C,Ios,我知道如何从NSSURL获取数据,但我想问我如何过滤数据,比如页面包含文本、图像、视频等,我如何指定like仅用于提取图像。如果所有的数据都一起下载了,我怎么过滤呢 - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ NSLog(@"%@",str); [receivedData appendData:data]; } 就像这样,如果所有数据都一起下载,我如何过滤。或
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
NSLog(@"%@",str);
[receivedData appendData:data];
}
就像这样,如果所有数据都一起下载,我如何过滤。或在下载前指定数据类型。提前thx从
nsurresponse
可以检查MIMEType
NSURLResponse * httpResponse = (NSURLResponse *) response;
NSString *fileMIMEType = [[httpResponse MIMEType] lowercaseString];
您可以考虑使用这个委托方法,用于<代码> NSURLCONNECT/<代码> < /P>
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
NSString *mime = [response MIMEType];
//do something with mime
}