• 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: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)


  • Subject: Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)
  • From: Greg Titus <email@hidden>
  • Date: Wed, 19 Nov 2008 07:29:34 -0800


On Nov 19, 2008, at 7:00 AM, Brian Stern wrote:

This leaves us for now with two solutions:
(a) Greg's (override setView:) which is more future-proof but is in many respects academically unsatisfying.
(b) For non-top-level-object, specify an assign attribute for the property -- and risk dangling pointers.

The override of setView is very similar to the viewDidUnload callback that I proposed as a solution for this. It has its own further issues. UIViewController calls [setView:nil] from its dealloc method so the subclass has to be prepared for this. What I've done is to add all the public retain properties for all the outlets. Additionally I've added a


-(void)releaseOutlets

method that uses the properties and sets them all to nil. I call this method from my subclass's dealloc method and setView: override. That way I only have one place to write the code that releases all the outlets.


Brian,

What is your reason for having a separate -releaseOutlets method to do this?

The sample that I gave (calling self.anOutlet = nil; when the argument to -setView: is nil) will do whatever releasing is required (if the anOutlet property is "retain") or simple zeroing the pointer (if the anOutlet property is "assign"). The fact that UIViewController calls - setView:nil from its -dealloc is just additional convenience. All of your outlets get cleaned up at the same time as the UIViewController cleans up the main view. There is no need to write any outlet related code in your -dealloc at all, since it is all handled via the superclass and the -setView: override.

In short, the way I think of it, -setView: _IS_ the one centralized place that deals with all view-related pointers, including all outlets. And UIViewController calls -setView: at all the necessary times (setup, memory warning, dealloc), so you don't have to do anything else.

Hope this helps,
	- Greg
_______________________________________________

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: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)
      • From: Brian Stern <email@hidden>
References: 
 >Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects) (From: Erik Buck <email@hidden>)
 >Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects) (From: Brian Stern <email@hidden>)
 >Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects) (From: mmalcolm crawford <email@hidden>)
 >Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects) (From: Brian Stern <email@hidden>)

  • Prev by Date: RE: display callbacks
  • Next by Date: Re: Writing a more usable AppleEvent logger
  • Previous by thread: Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)
  • Next by thread: Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)
  • Index(es):
    • Date
    • Thread