Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 08-25-2009, 11:23 AM   #4 (permalink)
BenClayton
Registered Member
 
Join Date: Aug 2009
Posts: 1
Default

Sorry to reopen this thread after such a long time, but I've been searching for a simple answer to this question and this was one of the posts that came up in Google.

Essentially if you use interface builder to connect an IBOutlet instance variable to a control, you must always release said IBOutlet in your own -dealloc method.

e.g. in your .h file.

@interface MyView : UIViewController {
IBOutlet UILabel *myLabel;
}
@end

.m file..

-(void) dealloc {
[super dealloc];

// release all IBOutlets..
[myLabel release];
}

You always need to do this, even if you have defined a retain property for the IBOutlet. The reason for this is that loadFromNib will call setValue:withKey for each IBOutlet on your view controller class, which uses the property's setter method or retains the object by default if no setter method is available. There's no system to automatically release things created by the NIB so you need to manually release them yourself.

[Reference: ]Resource Programming Guide: Nib Files. Also see lecture 11 of CS193P at Stanford on iTunes U if it's still available - about 57 minutes in.

Regards,
Ben
BenClayton is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,862
Threads: 89,223
Posts: 380,684
Top Poster: BrianSlick (7,129)
Welcome to our newest member, higgey
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:35 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.