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

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

问题描述

我有一个 iPhone 程序,它应该在给定文件名列表的情况下执行智能操作(为文件类型挑选合适的图标).我正在寻找 iPhone 上的类似/etc/mime.types 或类似的东西 - API 调用是我假设手机可用的.这存在吗?

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?

编辑

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

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天全站免登陆