Question

I am attempting to use a iCloud-enabled UIDocument with a directory-based NSFileWrapper (aka File package) to maintain a complex application state. In my app, the user can have many distinct configurations (kind of like cars that have seat settings for each potential driver).

For each individual state I add a regular file NSFileWrapper to the overall file package.

The writing and reading of my UIDocument into/from the cloud is working fine. I also get notifications when the file package has changed.

The problem is that I can't figure out from the notification which of the additions or changes to the sub files (i.e., states) caused the package to change.

I've tried overriding the presentedSubitemDidChangeAtURL in my custom UIDocument but that only gives me the URL of the package. I've also experimented with the file wrapper's matchesContentsOfURL method, but that doesn't seem to be right since the child file wrappers don't have a "real" URL.

Comments and suggestions welcomed.

Was it helpful?

Solution

I ended up addressing this problem by checking each regular file's modification date against a locally stored NSDate. As the UIDocument gets updated, I check to see which items were changed after the last time I ran the process loop. Some care needs to be taken such that locally updated files aren't processed again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top