Upgrading app's UIDocument format from Data to FileWrapper?

Hi,


I had a document-based iOS app working, but want to change it so it saves to a package. Seems like it's better when big chunks of a file may not be changing. In Xcode, under the Target > Info > Exported UTI > Conforms To, I had: "public.data, public.content". If I change that to "com.apple.package", then I can't open my old files to upgrade them. But if I *add* "com.apple.package", then the app opens both kinds as desired.


I wonder if having it conform to all three of those types is going to cause other problems.


Rob

I don't know whether the multiple types is going to be a problem, but why can't you declare a different UTI for the package, and declare a different file type referencing this new UTI. You would need to use a different extension for the package, since the extension controls which UTI and file type are used, but that shouldn't be a problem on iOS, where file extensions are not usually user-visible.


The only complication is that you have to arrange for an open of a document of the old type to save as a document of the new type. UIDocument should provide for this, but you'd also need to decide how to handle the left-over file, since you're not physically overrwriting it any more.

I may end up doing what you suggest. I don't know how at the moment, but I just found the UIDocument property `savingFileType`, and that may be the key.


I wasn't thrilled with having an second file extension after using the obvious ".myappname" for the first one.


Ideally I'd have one extension, and a way to tell the system that it's "com.apple.package", but to also let my app open it if it's a plain file ("public.content, public.data"). As it is, if I take those two types out of the "Exported UTIs > Conforms To" field, then I can't tap on and open the old documents.

In one of my apps, I changed from raw data to a file package. New extension: .myappname2 😉

Upgrading app's UIDocument format from Data to FileWrapper?
 
 
Q