Ray*_*ich 9 nsfilewrapper ios icloud
我有一个使用基于NSFileWrapper的UIDocument的应用程序.我的文件包装器是一个名为"XXX.cp"的目录,有两个子文件"photo.data"和"photo.metadata".它似乎可以保存和加载文档,但是当我转到Settings\Manage Storage\Unknown时,子文件会单独列出:

我期待它显示"XXX.cp"而不是这两个子文件.我想我已经正确设置并导出文件UTI:

我认为我正在创建文件包装器(特别是因为它读/写正常):
- (void)encodeObject:(id<NSCoding>)object toWrappers:(NSMutableDictionary *)wrappers preferredFilename:(NSString *)preferredFilename {
@autoreleasepool {
NSMutableData * data = [NSMutableData data];
NSKeyedArchiver * archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:object forKey:@"data"];
[archiver finishEncoding];
NSFileWrapper * wrapper = [[NSFileWrapper alloc] initRegularFileWithContents:data];
[wrappers setObject:wrapper forKey:preferredFilename];
}
}
- (id)contentsForType:(NSString *)typeName error:(NSError *__autoreleasing *)outError {
if (self.captionedPhotoMetadata == nil || self.captionedPhoto == nil) {
*outError = [[NSError alloc] initWithDomain:CaptionedPhotoErrorDomain code:CaptionedPhotoInvalidDocument userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Invalid document!", @""), NSLocalizedDescriptionKey, nil]];
return nil;
}
NSMutableDictionary * wrappers = [NSMutableDictionary dictionary];
[self encodeObject:self.captionedPhotoMetadata toWrappers:wrappers preferredFilename:METADATA_FILENAME];
[self encodeObject:self.captionedPhoto toWrappers:wrappers preferredFilename:DATA_FILENAME];
NSFileWrapper * fileWrapper = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:wrappers];
return fileWrapper;
}
Run Code Online (Sandbox Code Playgroud)
但仍然没有雪茄.谁知道问题是什么?谢谢!
| 归档时间: |
|
| 查看次数: |
1904 次 |
| 最近记录: |