Re: How to enforce a single NSDocument ... or should I do something else?

2010-01-06 Thread Bill Cheeseman
No, I created a custom error number and message, and presented an alert accordingly. Bill On Jan 6, 2010, at 8:10 AM, Martin Stanley wrote: > By the way, I can't seem to find the "document-already-open" error. Is it a > standard error code? -- Bill Cheeseman b...@cheeseman.name _

Re: How to enforce a single NSDocument ... or should I do something else?

2010-01-06 Thread Martin Stanley
Thanks very much, Bill. I like your approach and in fact I think our scenarios are quite similar so I'm going to implement your solution. By the way, I can't seem to find the "document-already-open" error. Is it a standard error code? Martin On 2010-01-05, at 3:26 PM, Bill Cheeseman wrote:

Re: How to enforce a single NSDocument ... or should I do something else?

2010-01-05 Thread Mike Abdullah
On 5 Jan 2010, at 17:34, Martin Stanley wrote: > Thanks for the very quick response! > > I don't quite understand step 2: how do I decide what to return from > -openDocumentWithContentsOfURL: if the callback hasn't been called yet and > therefore I don't know if the user cancelled the close

Re: How to enforce a single NSDocument ... or should I do something else?

2010-01-05 Thread Martin Stanley
Thanks for the very quick response! I don't quite understand step 2: how do I decide what to return from -openDocumentWithContentsOfURL: if the callback hasn't been called yet and therefore I don't know if the user cancelled the close of the first document? I think the basic problem for me i

Re: How to enforce a single NSDocument ... or should I do something else?

2010-01-05 Thread Mike Abdullah
Override -openDocumentWithContentsOfURL: 1. If you've already got a document open, send -canCloseDocument… to the open document, supplying the callback info 2. Either: A) Return nil and an NSUserCancelled error. B) Return the existing document. 3. When you get the callback from

How to enforce a single NSDocument ... or should I do something else?

2010-01-05 Thread Martin Stanley
I have a Core-Date application that uses the Cocoa Document architecture (NSPersistentDocument) and would like to ensure that the user only can have 1 document open at a time. Think of this application as similar to Mail.app or Addressbook.app, etc. except that I would like the user to be able t