Posts

Post not yet marked as solved
8 Replies
2.5k Views
I am trying to make my document icons show up when for example attaching in Mail app. This is the Info.plist which I have:<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeExtensions</key> <array> <string>poz</string> </array> <key>CFBundleTypeIconFiles</key> <array> <string>icon_320x320.png</string> <string>icon_64x64.png</string> <string>icon_22x29.png</string> <string>icon_44x58.png</string> <array/> <key>CFBundleTypeName</key> <string>POZ Doc</string> <key>CFBundleTypeRole</key> <string>Editor</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.company.app.poz</string> </array> <key>LSTypeIsPackage</key> <true/> <key>NSDocumentClass</key> <string>App.POZDocument</string> </dict> </array> <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.composite-content</string> <string>com.apple.package</string> </array> <key>UTTypeDescription</key> <string>POZ Doc</string> <key>UTTypeIconFiles</key> <array> <string>icon_320x320.png</string> <string>icon_64x64.png</string> <string>icon_22x29.png</string> <string>icon_44x58.png</string> <array/> <key>UTTypeIdentifier</key> <string>com.company.app.poz</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>poz</string> </array> </dict> </dict> </array> The exporting and importing all works fine. However, the icon is just not showing up in the attachment. The icon sizes seem to be correct as per Apple documentation.What am I missing? Do I have to add something to my App.POZDocument?
Posted Last updated
.
Post not yet marked as solved
1 Replies
269 Views
I am trying to open a custom UIDocument with document.open.Below is the following code for my custom UIDocument:import UIKit import Foundation import MobileCoreServices class POZDocument: UIDocument { var surveyData: Data! { didSet{ updateChangeCount(.done) } } var mediaFiles: Data? { didSet{ updateChangeCount(.done) } } override func contents(forType typeName: String) throws -> Any { let contents = FileWrapper(directoryWithFileWrappers: [String: FileWrapper]()) if let newSurveyData = surveyData { let surveyQuestionsTabSeperatedContent = FileWrapper(regularFileWithContents: newSurveyData) surveyQuestionsTabSeperatedContent.preferredFilename = "surveyData.dat" contents.addFileWrapper(surveyQuestionsTabSeperatedContent) //for Questions' Media File if mediaFiles != nil { let mediaContent = FileWrapper(regularFileWithContents: mediaFiles!) surveyQuestionsTabSeperatedContent.preferredFilename = "mediaData.dat" contents.addFileWrapper(mediaContent) } } return contents } override func load(fromContents contents: Any, ofType typeName: String?) throws { let contentWrapper = contents as! FileWrapper let fileContents = contentWrapper.fileWrappers for (fileName,fileWrapper) in fileContents! { if fileName == "surveyData.dat" { surveyData = fileWrapper.regularFileContents! } else { mediaFiles = fileWrapper.regularFileContents! } } } }However, when I open the document from say the email app, in func load(), "let contentWrapper = contents as! FileWrapper" gives the following error:Could not cast value of type 'OS_dispatch_data' (0x103810978) to 'NSFileWrapper' (0x1b3ae4ac0).I even typed "com.apple.package" under Exported UTIs 'Conforms To' textfield to handle such documents.What am I missing?
Posted Last updated
.