标签:nullable lan com error cfs 需要 pre sts oct
1. [[[NSURLSession sharedSession] dataTaskWithURL:[NSURL fileURLWithPath:@"/Users/xiaomage/Desktop/Snip20161126_238.png"] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
2.
3. //响应头信息:对服务器端已经对响应本身的描述
4. NSLog(@"%@",response.MIMEType);
5. }]resume];
1.- (NSString *)mimeTypeForFileAtPath:(NSString *)path
2.{
3. if (![[[NSFileManager alloc] init] fileExistsAtPath:path]) {
4. return nil;
5. }
6.
7. CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)[path pathExtension], NULL);
8. CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType);
9. CFRelease(UTI);
10. if (!MIMEType) {
11. return @"application/octet-stream";
12. }
13. return (__bridge NSString *)(MIMEType);
14.}
?重要
:C语言API方法需要依赖于【<MobileCoreServices/MobileCoreServices.h>
】头文件。
1.// 通用的二进制数据类型
2.application/octet-stream
标签:nullable lan com error cfs 需要 pre sts oct
原文地址:http://www.cnblogs.com/leilifengixng/p/6367518.html