I have an app that uses a UIManagedDocument (i.e., Core Data) document format. To keep life interesting I am trying to get it to work with iCloud. I have managed to get to the point where I can get one of the following two options:
- It works but in the iCloud settings the documents all appear as
DocumentMetadata.plist
which, needless to say, is pretty confusing - Existing documents display correctly in the iCloud settings but I cannot create new ones
Obviously neither of these is acceptable (though clearly the second is the worst.)
In scenario one, I do not have an document types or Exported UTI types and I set up my NSMetadataQuery
to look for the DocumentMetadata.plist
(since that's a file and the query can only find things that are considered to be files).
In scenario two, I do have both document types and Exported UTI types defined. In this case the NSMetadataQuery
looks for the file extension of my document type. The weird thing in this case is that the saveToURL:completionHandler:
method never calls the completion block:
[docToOpen saveToURL:docURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success){
NSLog (@"This line never gets executed.";
}];
(It does in the first case.)
My guess -- and it is a guess -- is that it uses the same mechanism as NSMetadataQuery
to see when the file "guts" of the document gets created but, because my document is a com.apple.package
it can't see inside and thinks that it's not finished.
What am I missing? Are you just not supposed to put managed documents in the user visible part of iCloud?