Re: UIDocument's fileType reports wrong UTI.
Re: UIDocument's fileType reports wrong UTI.
- Subject: Re: UIDocument's fileType reports wrong UTI.
- From: Half Activist <email@hidden>
- Date: Wed, 23 Oct 2013 15:17:55 +0200
Here's the Info.plist section
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>typeA</string>
</array>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>Document Type A</string>
<key>LSItemContentTypes</key>
<array>
<string>com.mycompany.typeA</string>
</array>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>typeB</string>
</array>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>Document Type B</string>
<key>LSItemContentTypes</key>
<array>
<string>com.mycompany.typeB</string>
</array>
</dict>
</array>
On Oct 23, 2013, at 3:10 PM, Mike Abdullah <email@hidden> wrote:
>
> On 23 Oct 2013, at 13:08, Half Activist <email@hidden> wrote:
>
>> Hello,
>>
>> In an iOS project, that is supposed to handle different kind of files, I declared in Info.plist the types handled, with two UTI types, say com.mycompany.typeA and com.mycompany.typeB. I also added the expected filename extensions for the two, suppose it's .typeA and .typeB.
>>
>> Now, I instantiate my UIDocument, with the following code: (all inspired by UIKit docs, I stripped off some details for the sake of lisibility, the file is guaranteed not to exist in the app folder.)
>>
>> NSString *newDocumentPath = [ AppDocumentPath() stringByAppendingPathComponent: @"NewDocument.typeA" ];
>> // Gives me a valid path to <AppHome>/Documents/NewDocument.typeA
>>
>> NSURL *newDocumentURL = [ NSURL fileURLWithPath: newDocumentPath ];
>> // Creates a file:// for that path.
>>
>> MyDocument *newDocument = [ [ MyDocument alloc ] initWithFileURL: newDocumentURL ];
>> // Instantiates the doc
>>
>>
>> // Finally present.
>> [ newDocument saveToURL: newDocumentURL
>> forSaveOperation: UIDocumentSaveForCreating
>> completionHandler: ^(BOOL success) {
>> [ self presentViewController: newDocument.viewController animated: YES completion: ^(){} ];
>> } ];
>>
>>
>> There, in the process of saving, in UIDocument's - (id)contentsForType:(NSString *)typeName error:(NSError **)outError
>> typeName is dyn.age81u5dmr3wu, not conforming to UTI for typeA or typeB.
>> The url is correct.
>>
>> At any other point in the execution, fileType reports the wrong type.
>>
>> With a colleague, we tried on another app where it wasn't checked for since it handles only one file format, and it's exactly the same, fileType returns another UTI from the one declared in the Info.plist.
>>
>> All of this under iOS7.
>
> Show us the relevant portion of your Info.plist file too, please.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden