Creating the Project
Round Rect Button
Figure 1. Populating the View window
In the OfflineReaderViewController.xib file, add in the following statements in bold:
Figure 2. Confirmation the connections of the action and outlet
Figure 3. Adding two files to the Resources folder of the project
In the OfflineReader-Info.plist file, set the “Icon file” key to “icon.jpg”.
Exporting Documents
Figure 4. A PDF document in Mail
Figure 5. Viewing your application in an external application
In my case, it will display the list as shown in Figure 6.
Figure 6. A list of applications able to handle your document
Next, define the following methods:
Finally, in the viewDidLoad method, add the following statement:
Figure 7. Exporting our PDF document to an external application
If you select iBooks, the PDF document will appear in iBooks (see Figure 8).
Figure 8. iBooks showing our PDF document
File Sharing
- File Sharing through iTunes
- Through exchanges between applications (like the one you just saw in the previous section)
Figure 9. Adding a new key to enable file sharing for your application
Figure 10. The application is now listed under the File Sharing section of iTunes
Figure 11. Copying a document into the application
Figure 12. Displaying the files in the Documents folder and loading the PDF document
Importing Documents
Add the new CFBundleDocumentTypes key as shown in Figure 13.
Figure 13. Add a new key to support PDF documents
- The CFBundleDocumentTypes key is of type Array. It contains an array of dictionaries describing the types of documents supported by your application.
- Item 0 is of type Dictionary.
- The CFBundleTypeName key specifies the abstract name for the specified document type.
- The LSHandlerRank key specifies whether the application is the owner (creator of this file type), Alternate (secondary viewer of this file type), None, or Default.
- The CFBundleTypeRole key specifies the application’s role with respect to the type - Editor, Viewer, Shell, or None.
- The LSItemContentTypes key is of type Array. It contains an array of UTIs specifying the file type.
Hence, add the following in the OfflineReaderAppDelegate.m file:
Figure 14. Your application is capable of handling PDF document
Figure 15. Confirming the path of the document in the Documents/Inbox folder
Importing Self-Defined Documents
Figure 16. Adding new keys to support self-defined document types
Figure 17. Opening a file of type .sdk