• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
count how many NSPersistentDocument instances are open, and detect document close
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: count how many NSPersistentDocument instances are open, and detect document close
      • From: mmalc crawford <email@hidden>
  • Prev by Date: NSAffineTransform isn't applied on NSCustomImageRep on Leopard
  • Next by Date: CoreImage problems with very large images
  • Previous by thread: NSAffineTransform isn't applied on NSCustomImageRep on Leopard
  • Next by thread: Re: count how many NSPersistentDocument instances are open, and detect document close
  • Index(es):
    • Date
    • Thread