in the Stack Overflow posting:
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:
- Alan’s code references an object called
managedDocumentDictionary,
but does not explain how to create it so I get an ‘undeclared
identifier’ compilation error. - Alan starts out stating that he wants to create a helper method to
retrieve aUIManagedDocument, 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:
- A helper Class definition,
- How does one get the ball rolling, i.e., where do I initially create this
UIManagedDocument, - Once created, How do I get the document in other TableViewControllers?
- A sample of where this should be invoked – in the AppDelegate? or each TableViewController?
- Maybe even a sample project?
Thanks to all for any interpretations you can offer.
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.