Re: count how many NSPersistentDocument instances are open, and detect document close
Re: count how many NSPersistentDocument instances are open, and detect document close
- Subject: Re: count how many NSPersistentDocument instances are open, and detect document close
- From: mmalc crawford <email@hidden>
- Date: Fri, 16 Nov 2007 07:56:34 -0800
On Nov 15, 2007, at 11:53 PM, Hal Mueller wrote:
I need to do two things. First, I need to count the open documents.
I see -orderedDocuments on NSApplication, and -documents on
NSDocumentController, both of which return an NSArray that I can
count. Is there any reason to prefer one over the other, given that
I am using NSPersistentDocuments and not simply NSDocuments?
Second, I need to detect document closing. The case I'm looking for
is where multiple documents where open (external sensors illegal),
and now they've been closed, except for one, so external sensors are
now legal. I'm thinking just override -close in my
NSPersistentDocument subclass, and test for the case where
openDocumentCount has just become 1. I don't care that -close is
not called on app quit, since there will be no more work done
anyway. Is this a good approach?
Why not create a subclass of NSDocumentController that manages all
this -- it's the object responsible for managing the documents, has
all the relevant information, is told when documents close, and can
readily message all the documents when state changes...
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden