count how many NSPersistentDocument instances are open, and detect document close
count how many NSPersistentDocument instances are open, and detect document close
- Subject: count how many NSPersistentDocument instances are open, and detect document close
- From: Hal Mueller <email@hidden>
- Date: Thu, 15 Nov 2007 23:53:39 -0800
My app connects to some external sensor hardware. For simplicity,
all of the external devices point to the same single
NSPersistentDocument instance (call it the "live document").
If more than one document is open, user can work with the documents,
perform analysis, etc., but is not allowed to connect the external
sensors. In this case there is no "live document".
If there is a "live document", that means that data acquisition is
happening, and no further documents are allowed to be opened.
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?
TIA,
Hal
_______________________________________________
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