• 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
When should one call unbind:? (in a GC application)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

When should one call unbind:? (in a GC application)


  • Subject: When should one call unbind:? (in a GC application)
  • From: "Sean McBride" <email@hidden>
  • Date: Wed, 31 Oct 2007 15:03:23 -0400
  • Organization: Rogue Research

For a long time, Apple recommended calling -unbind in a view's -dealloc
method.  With the introduction of garbage collection, this had to
change.  The new Apple recommendation became:

- (void)viewWillMoveToSuperview:(NSView*)newSuperview
{
 	[super viewWillMoveToSuperview:newSuperview];
 	if (newSuperview == nil)
 	{
 		[self unbind:...];
 	}
}

as documented here:
<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html#unbinding>

Apple highly discourages doing work in -finalize, so this seems like a
good idea.

However, if you use 10.5's new NSView API:
- (BOOL)enterFullScreenMode:(NSScreen*)screen
    withOptions:(NSDictionary*)options

then the unbinding is triggered, because viewWillMoveToSuperview: is
called with nil.  Obviously, we don't want everything unbound, just
because we are fullscreen.

Now I don't know where to call -unbind.  Doing it in -finalize seems
dangerous, what with Apple discouraging it so much.

This is <rdar://5497135> BTW.

Thanks,

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada

_______________________________________________

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: When should one call unbind:? (in a GC application)
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Re: reordering table cells with 10.5 sdk
  • Next by Date: Re: Problem loading Nib
  • Previous by thread: Re: Attributed string in user defaults, is RTFD data OK?
  • Next by thread: Re: When should one call unbind:? (in a GC application)
  • Index(es):
    • Date
    • Thread