文档类型与导出和导入的UTI [英] Document Types vs. Exported and Imported UTIs

查看:171
本文介绍了文档类型与导出和导入的UTI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释Xcode 5.1中的文档类型,导出的UTI和导入的UTI之间的区别吗?我希望能够让我的应用根据文件扩展名自动检测文件类型.为此,我需要实施这三个中的哪一个?

Can anyone explain to me the difference between Document Types, Exported UTIs and Imported UTIs in Xcode 5.1? I want to be able to have my app automatically detect file type based on file extension. Which of these three would I need to implement in order to do that?

推荐答案

您添加了文档类型以注册您的应用可以打开该文档类型,当您选择已知文件类型,但如果该文件类型未知,您还必须在导入的UTIs 中对其进行定义.而且,如果您要定义自己的文件类型,则必须在导出的UTIs 中声明它,并添加该 Document Type 才能打开它.

You add a Document Type to register that your app can open that Document Type, this is simple when you select a known file type, but if the file type is not known, you must also define it in Imported UTIs. And if you are the defining your own File Type you must declare it in Exported UTIs and add that Document Type to be able to open it.

示例:

我想打开PDF,这是一种已知的文件类型,所以我只在文档类型中注册它.

I want to open a PDF, which is a known file type, so I just register it in Document Types.

我想打开一个未知文件类型的EPUB,因此我将其注册到导入的UTI 文档类型中.

I want to open an EPUB, which isn't a known file type, so I register it in Imported UTIs and in Document Types.

我想打开并注册一个我有权使用的类型,因此我在导出的UTIs 文档类型中注册了它.

I want to open and register a type that I'm authoritative of, so I register it in Exported UTIs and in Document Types.

关于第二个问题,请注意,使用文档类型定义类型将使您的应用显示在打开方式"对话框中,但不一定会使您的应用区分您的应用所接收的文件类型,您必须照顾好自己.例如,假设您的应用程序是图像编辑器,并且您同时注册了png和jpeg类型,那么当用户想要编辑图像时,您的应用程序会收到该文件,但不会检测到哪种类型是自动的,您可以必须处理文件并响应文件的任何类型.

As for your second question, please note that defining a type using a Document Type will make your app appear in the "Open in" dialog, but not necessarily will make your app distinguish between which type of file your app is receiving, you must take care of handling that yourself. For example, let's say that your app is an image editor, and you registered both png and jpeg types, when the user wants to edit an image your app will receive the file but it won't be detecting which type is automatically, you'll have to process the file and respond to whatever type it is.

一些相关链接:

相关问题.

关于这个主题的很好但很旧的教程

这篇关于文档类型与导出和导入的UTI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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