简体   繁体   中英

How to get UIManagedDocument to show up as a file package and not a folder

I'm working on a Core Data document based application, using a UIManagedObject subclass as my storage container.

When saving the file (to iTunes File Sharing) the file shows up as a folder, instead of a file package. I'd like it to show up as a single file so users can't accidentally mess with the file structure.

Here's what I've done so far. In my subclass :

@implementation

- (NSString *)savingFileType {
    return @"com.app.filetype";
}

- (NSString *)fileNameExtensionForType:(NSString *)typeName
                         saveOperation:(UIDocumentSaveOperation)saveOperation {
    return @"ext";
}

@end

In the target info, I register the exported UTI :

在此输入图像描述

And... I finally figured it out.

In the "Exported UTIs" section of your info.plist, add "com.apple.package" to the "Conforms To" field of your custom UTI. 在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM