Home > Articles > Mobile Application Development & Programming

  • Print
  • + Share This
This chapter is from the book

Declaring Document Support

Documents can declare their support for certain file types in their Info.plist property list. This kind of declaration is part of the Launch Services system and is similar to declarations made on OS X. Figure 16-6 shows one such document declaration.

The CFBundleDocumentTypes array lists each file type supported by the application. Each item in this list is a dictionary that corresponds to the declarations you read in earlier using the UTTypeCopyDeclaration()function. Most importantly, the dictionary needs to list its content types, namely the supported UTI or UTIs. In Figure 16-6, that type is public.data, which means the application will allow itself to open pretty much any iOS file, and its name, here com.sadun.public-data. As you can tell, this is an arbitrary string.

To associate an icon with the file data, you can add bundle images to the dictionary’s CFBundleTypeIconFiles array. For simplicity, this declaration uses the application’s icon, but you can create more document-specific icons as required.

Figure 16-6

Figure 16-6. Declare supported document types in your Info.plist property list.

The handler rank key specifies how to rank the application. Choices include Owner, Default, and Alternative. The rules for these are as follows. An owner should be the natural creator and editor of a given file. I use owner in this example just because it’s more or less to be guaranteed to be given priority for opening documents, which is handy when testing out application-to-application document sharing. The default application says to launch services that it’s the most preferred application for opening a file type, even if it is not the document creator. For the most part, you’ll want to use “alternative”, which states that your application is one of many that can display or edit a given file type.

  • + Share This
  • 🔖 Save To Your Account