I have an app that uses a UIDocument that is NSFileWrapper based. My file wrapper is a directory named "XXX.cp", with two sub-files "photo.data" and "photo.metadata". It seems to save and load documents fine, however when I go to Settings\Manage Storage\Unknown the sub-files are listed separately:
I was expecting it to show "XXX.cp" instead of these two sub-files. I think I have the document UTI set up and exported properly:
And I think I am creating the file wrappers correctly (especially since it reads/writes fine):
- (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;
}
But still no cigar. Anyone know what the problem is? Thanks!