• 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 00:10:17 -0500


On Nov 17, 2008, at 11:51 PM, mmalcolm crawford wrote:


On Nov 17, 2008, at 7:12 PM, Brian Stern wrote:

On Nov 17, 2008, at 9:11 PM, mmalcolm crawford wrote:

One other consideration, particularly in iPhone applications, is where you might have outlets to subviews of a main view that might be released in sime situations -- e.g. a UIViewController whose view is released in didReceiveMemoryWarning. To ensure that you don't prolong the lifetime of objects you got from the nib, you should set (use your accessor methods to) set those variables to nil in the relevant method, e.g.:

@interface MyController : UIViewController {
UILabel *label;
...
}
@property (nonatomic, retain) IBOutlet UILabel *label;

then

- (void)didReceiveMemoryWarning {
 self.label = nil;
 [super didReceiveMemoryWarning];
}

OK, this issue has come up for me very recently. It appears that on iPhoneOS IBOutlets are retained, regardless of the presence of properties.


No, on iPhone outlets are consistently *not* retained -- which is precisely why you do need to retain top-level objects on iPhone. But absent accessor methods, connections are made using KVC...
This is documented here:
<http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/chapter_3_section_4.html#//apple_ref/doc/uid/10000051i-CH4-SW6 >

That's the vague documentation that I referred to. What you're telling me is that where it says should in that paragraph it really means must. OK, that's what I figured out a few days ago.


Where it says that it "retains the object by default if no setter method is available", that seems to contradict what you say about outlets not being retained. Actually I didn't really absorb that statement before. It means that if there's no property then the outlet will be retained. OK.

My experience with the assign property is contrary to what the docs seem to be saying. I think the outlet is retained even if there is an assign property.

As I stated originally, following the pattern I describe above makes memory management consistent in all situations.

I simply don't need properties for all my Outlets, except for this issue. I also don't really like making all my outlets implicitly public. But I'm forced to do that.



-- 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: Jonathan Hess <email@hidden>
    • Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)
      • From: Luke the Hiesterman <email@hidden>
References: 
 >Interface Builder & Wiring Objects (From: Greg Deward <email@hidden>)
 >Re: Interface Builder & Wiring Objects (From: Randall Meadows <email@hidden>)
 >Re: Interface Builder & Wiring Objects (From: Greg Deward <email@hidden>)
 >Re: Interface Builder & Wiring Objects (From: Andy Lee <email@hidden>)
 >Re: Interface Builder & Wiring Objects (From: mmalcolm crawford <email@hidden>)
 >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>)
 >Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects) (From: mmalcolm crawford <email@hidden>)

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