Question

in the Stack Overflow posting:

How do I create a global UIManagedDocument instance per document-on-disk shared by my whole application using blocks?

Alan asked how to create a global UIManagedDocument to be used throughout his entire app. He provided code slices of his attempt. Kevinpo provided an answer which made perfect sense to Alan.

But I started out with the same problem, and can't make heads or tails out of their collective postings.

Specifically:

  1. Alan's code references an object called managedDocumentDictionary, but does not explain how to create it so I get an 'undeclared identifier' compilation error.
  2. Alan starts out stating that he wants to create a helper method to retrieve a UIManagedDocument, yet throughout both his and Kevin's code, neither actually show defining a helper method with .h and .m files.

So, if possible, can anyone make sense of what they are saying and help me understand how it all fits together? Perhaps:

  1. A helper Class definition,
  2. How does one get the ball rolling, i.e., where do I initially create this UIManagedDocument,
  3. Once created, How do I get the document in other TableViewControllers?
  4. A sample of where this should be invoked - in the AppDelegate? or each TableViewController?
  5. Maybe even a sample project?

Thanks to all for any interpretations you can offer.

Was it helpful?

Solution

That post shows how to access a document, based on a name. The dictionary is a mapping from names to UIManagedDocument instances. Thus, he can ask for document @"Foo" and the code will go look up @"Foo" in the dictionary. If it is there, the UIManagedDocument will be returned. If it is not there, then a new one will be created and placed in the dictionary (and the passed-in completion block will be called).

His question was basically, how to pass a completion block to the function, and have that function call the completion block he passed in.

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