• 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: Implementing binding with garbage collection.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Implementing binding with garbage collection.


  • Subject: Re: Implementing binding with garbage collection.
  • From: mmalc crawford <email@hidden>
  • Date: Thu, 8 Nov 2007 13:10:12 -0800


On Nov 8, 2007, at 12:52 PM, Joshua Emmons wrote:
The basic premise is that I have an NSView subclass in a GC-Required app which has an NSArray* property called contentArray. I would like to bind contentArray to the arrangedObjects property of an NSArrayController. In this case, my NSView subclass conveniently contains an outlet to said controller. My code therefore looks something like this:
[...]
-(void)finally{
[self.observedObject removeObserver:self forKeyPath:self.observedKeyPath];
self.observedObject = nil;
self.observedKey = nil;
}
@end


My concern is with the -finally. I basically just moved my -dealloc code over there, but in doing so I'm explicitly performing two of the things the documentation says never to perform in -finally:
"To make your finalize method as efficient as possible, you should typically not do any of the following:
o Set instance variables to nil
o Remove self as an observer of a notification center (in a garbage collected environment, notification centers use zeroing weak references)."
Now to be fair, it's not a notification center that I'm observing, but it's been suggested the same applies?


No, the same does not apply (unfortunately).

All of this combines to make coding a binding implementation even more convoluted than it was in 10.4. I feel certain that can't be the case and that I am again overlooking something. Does anyone have experience to share?

<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html#unbinding>
You can use viewWillMoveToSuperview:.
Note that this only works if your view is not going to become full- screen, otherwise you will have to write a finalize method.


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: Implementing binding with garbage collection.
      • From: Ricky Sharp <email@hidden>
References: 
 >Implementing binding with garbage collection. (From: Joshua Emmons <email@hidden>)

  • Prev by Date: NSAppleScript - executeAndReturnError & suspendExecution
  • Next by Date: Re: [Leo] Strange Core Data vs. Spotlight issue
  • Previous by thread: Implementing binding with garbage collection.
  • Next by thread: Re: Implementing binding with garbage collection.
  • Index(es):
    • Date
    • Thread