On 29 Jan 2010, at 15:13, Jerry Krinock wrote:

> I want a notification that a document will close in order to do clean-up such 
> as:
> 
> 1.  Clear my intra-app copy/drag collections of any items in the closing doc.
> 2.  Unbind temporary bindings which I had bound in code.

Cocoa bindings unbind themselves when the observing object is deallocated. You 
shouldn't need to do anything special. For your own bindings, it's probably a 
good to make them behave similarly.

> 3.  Cancel NSURLConnections which may send messages to the doc.

What manages these connections normally?
> 
> I've been using -[NSDocument close], but in its documentation I read that 
> "This method may not always be called".   I've not experienced this.  When 
> might it not be called?  [1]

There are two possible scenarios:

A) The document is deallocated without -close ever being called
B) The application quits without needing to deallocate or close the document.

In practice, A won't happen unless you start manually allocating documents and 
deallocating without calling -close.

As of Snow Leopard, if an app declares itself suitable, we have fast 
termination. Rather than ask all documents to close, the process will be 
terminated without any methods being called. So, your documents never know that 
will/did close.
 
> 
> I cannot use -[NSWindow close] because I'm developing a framework which is 
> used in both an app and a background tool.  The latter opens documents but, 
> of course, no windows.
> 
> As always, the -dealloc method may be too late to avoid crashes.
> 
> Not using Garbage Collection.
> 
> Thank you,
> 
> Jerry Krinock
> 
> [1]  It also says that "Additional information on application termination can 
> be found in [another document] Graceful Application Termination."  But I read 
> the other document but did not find the answer, and also I'm interested in 
> what happens when the document closes without application termination.
> 
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
> 
> This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to