• 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: Brian Stern <email@hidden>
  • Date: Tue, 18 Nov 2008 13:01:46 -0500


On Nov 18, 2008, at 9:15 AM, Erik Buck wrote:

If you write correct accessors for all outlets, then the retain/ release memory management is entirely handled in one method. the - set retains the new value and releases the old value.

Any confusion regarding memory management for IB outlets seems to stem from failure to write the accessors and reliance on syntactic sugar. Just remember that

@property (nonatomic, retain) IBOutlet UILabel *label;

results in synthesis of the appropriate accessor methods. It does nothing more than save you some typing and document your intention. The -set method that results from the above property declaration retains the new value and releases the old value. The memory management is therefore all handled in one place just the way it should be and the way you want.

So what's the problem again ?

OK Erik, I'll bite. What you describe above is correct as far as it goes. However, when you say all the memory management is handled in one place, of course it's two. The object has to be released. The normal place to release objects is in their owner's dealloc method, and this also applies to outlets.


However, UIViewController has the ability to unload its view outlet in response to a memory warning. Any subclass should also release its outlets in response to the memory warning, if the base class releases its view, but not otherwise. So now there are three places to manage the memory of these outlets. The problem is that the base class doesn't always release its view in response to a memory warning and as far as I can tell the subclass has no clean way of telling if the view will be released or has been released. That's the problem.

--
Brian Stern
email@hidden



_______________________________________________

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

  • Prev by Date: Re: NSDateFormatter strangeness
  • Next by Date: Re: Regex
  • 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