iPhone MIME类型数据库在哪里? [英] Where's the iPhone MIME type database?

查看:221
本文介绍了iPhone MIME类型数据库在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序为iPhone,应该是做聪明的事情(挑选出适当的文件类型的图标)给出一个文件名列表。我正在寻找iPhone的东西像/etc/mime.types或类似的东西 - 一个API调用是我假设将可用于手机。这是否存在?

解决方案

如果是这样,您的应用程序肯定没有权限,



这是一个函数I写了一段时间。我为Mac写了它,但它看起来像在iPhone上存在的相同的功能。基本上,你给它一个文件名,它使用路径扩展来返回文件的MIME类型:

  #import< MobileCoreServices /MobileCoreServices.h> 
...
- (NSString *)fileMIMEType:(NSString *)file {
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension,(CFStringRef)[file pathExtension],NULL);
CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass(UTI,kUTTagClassMIMEType);
CFRelease(UTI);
return [(NSString *)MIMEType autorelease];
}


I have a program for the iPhone that is supposed to be doing intelligent things (picking out appropriate icons for file types) given a list of filenames. I'm looking for the iPhone take on something like /etc/mime.types or something similar- an API call is what I'm assuming would be available for the phone. Does this exist?

解决方案

If it did, your app surely wouldn't have permissions to even read it directly. What are you trying to do?

EDIT

This is a function I wrote a while ago. I wrote it for the Mac, but it looks like the same functions exist on the iPhone. Basically, you give it a filename, and it uses the path extension to return the file's MIME type:

#import <MobileCoreServices/MobileCoreServices.h>
...
- (NSString*) fileMIMEType:(NSString*) file {
    CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (CFStringRef)[file pathExtension], NULL);
    CFStringRef MIMEType = UTTypeCopyPreferredTagWithClass (UTI, kUTTagClassMIMEType);
    CFRelease(UTI);
    return [(NSString *)MIMEType autorelease];
}

这篇关于iPhone MIME类型数据库在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆