I am trying to save a plist and several binaries (like images) as part of a UIManagedDocument. The name of the binaries is an attribute in Core Data, and I do not need to list them, just refer to what you need when showing the related entity.
The file structure I want to have is:
- <File yyyyMMdd-HHmmss>.extdoc - StoreContent - persistentStore - AdditionalContent - ListStatus.plist (used to store per document defaults) - Images - uuid1.png - uuid2.png - ... - uuidn.png
So far, I have successfully followed the instructions in How to save additional content to my UIManagedDocument files? but when I try to add binaries there are some things that I don’t know how to do.
- Should I handle the URL / the / path / File yyyyMMdd-HHmmss.extdoc / AdditionalContent (readAdditionalContentFromURL is used by default: error :) as NSFileWrapper? Are there any advantages / disadvantages, and not just the use of URLs? It’s harder for me to use the file wrapper, since the plist needs to be read using file covers and NSCoder (I think), and the files, I have to store the file wrapper for the Images directory, and then get the corresponding node with objectForKey (suppose). But Apple’s iOS application programming guide for custom formats instead of NSData or NSFileWrapper says, “Keep in mind that your code will have to duplicate what UIDocument does for you, and therefore you need to deal with more complexity and greater chance of error. " I do not understand this?
- The default entries for documents are declared as properties: the setter modifies the NSDictionary, which displays a plist and marks the document as updated, and getter accesses the dictionary using the appropriate key. How to show the ability to read / write binary files? Should I add a method to my subclass of UIManagedDocument? - (void) writeImage: (NSString *) uuid; and - (UIImage *) readImage: (NSString *) uuid; And should you store this data in memory until the document is saved? How?
- Assuming NSFileWrapper is the way to go, if I plan to use this document with iCloud , should file coordinators with a file shell be used? If so, how?
Any source code for each question is welcome. Thanks.
PS: I know that I can save some binary data inside Core Data, but I do not feel comfortable with this solution. Among other reasons, I prefer to store PNG data for image files, which are a serialized version of UIImage that will not be compatible with NSImage if I want to create a desktop application.
source share