• 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
Re: count how many NSPersistentDocument instances are open, and detect document close
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: count how many NSPersistentDocument instances are open, and detect document close
      • From: Hal Mueller <email@hidden>
References: 
 >count how many NSPersistentDocument instances are open, and detect document close (From: Hal Mueller <email@hidden>)

  • Prev by Date: reading NSTableView cell edits before user tabs or enters
  • Next by Date: Re: IS-A relationships in core data
  • Previous by thread: count how many NSPersistentDocument instances are open, and detect document close
  • Next by thread: Re: count how many NSPersistentDocument instances are open, and detect document close
  • Index(es):
    • Date
    • Thread