views:

31

answers:

1

I use a .xib to layout my viewController and have 10 IBOutlet objects that IB uses, none of them have @properties assigned to them (no @property(retain) IBOutlet...). When I release the viewController none of those objects are being released, I have to manually release them in the dealloc of the viewController.

This doesn't seem like normal behavior, I thought that those objects would be released by the system since IB is whats assigning them, what could I be doing wrong?

+1  A: 

Apple's Memory Management Programming Guide tells you exactly how to properly release IBOutlets.

In short, you are supposed to release them in dealloc, but you also want to release them in viewDidUnload.

Robot K
Ah, is this new behavior in 4.x now that we have a viewDidUnload and it used to just handle it for you in 3.x?
Shizam
They are assigned to your ivars, so you own them, so you have to release them. *This has always been the case.* In the past, Leaks didn't detect certain kinds of garbage (it would never detect a leaked UIImageView); perhaps they fixed this. I also highly recommend using properties and using `self.foo = nil` instead; I cringe when I see code which releases ivars without setting them to nil.
tc.
Thanks, and agreed re: setting things to nil.
Shizam