• 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
Disconnecting my NSDocument from its Bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Disconnecting my NSDocument from its Bindings


  • Subject: Disconnecting my NSDocument from its Bindings
  • From: Tom Coates <email@hidden>
  • Date: Thu, 26 Oct 2006 22:20:08 -0700

I have an NSDocument based application. I'm trying to make it robust in the face of the user opening and closing multiple documents. I noticed that during my cocoa learning phase I had negelcted this, and my application's memory footprint would gradually grow and grow.
My main thrust has been to make sure that my NSDocument has a decent dealloc method. But I quickly discovered that dealloc wasn't being called by the standard application controls.


I found an old message on this list suggesting that Bindings might be the problem. Sure enough, my Document had a retaincount of 3 when I had my NSObjectController connected, but only of 1 without it. And without bindings, my dealloc method is called. That message suggested "breaking the bindings" during the documents close() method. That sounds reasonable, but I have a few questions about it.

1. How does one go about disconnecting from the NSObjectController?
2. Where should this disconnect be placed?
2. Why is this necessary? I would think this would be somehow automatic. Perhaps I've somehow broken the standard mechanism by some other customization. My application was started a long time ago, before bindings. Maybe I need to start over to get the most recent idioms.


I've searched quit a bit on this without any direct success. At least I know that others have similar problems. But complete understanding eludes me.

On the first problem (breaking bindings) I've found references to using NSObjectController's unbind, followed by a setContent:nil. But my NSDocument doesn't have a reference to the NSObjectController. Am I supposed to add an outlet for this purpose? And where should the disconnect go. In the -(void)close method??

Any suggestions would be appreciated.

Tom Coates :::/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Disconnecting my NSDocument from its Bindings
      • From: Mike Abdullah <email@hidden>
  • Prev by Date: Re: sort, cut and paste
  • Next by Date: Re: how to get an event (also name the event) when mac(universal i.e. or min 10.3.9 and above) wakes up from sleep mode
  • Previous by thread: Re: new Docoa (AppKiDo alternative)
  • Next by thread: Re: Disconnecting my NSDocument from its Bindings
  • Index(es):
    • Date
    • Thread