doing it wrong

Blogging with Class

Cocoa Pro-tip of the Day™, Part Two

Almost two weeks ago, I posted up a tip about Cocoa.  Having been knee deep in iPhone land, I had implicitly made the assumption that a) this applied to both the iPhone and MacOS X and that b) even if it didn’t, it was obvious that I was talking about the iPhone… Ooops.

Cocoa Pro-tip of the Day™

Anyway, at the very end of yesterday’s tech talk, Michael Jurewitz gave a great talk about optimizing iPhone applications.  And this very issue came up.  IBOutlet objects in iPhone OS require that they be freed up – but MacOS X does not.  This explains why there are bad examples on the web.  There are two conflicting ways to handle these objects depending on which platform you are working on.

Another point Michael brought up is that you should be releasing these in -(void)viewDidUnload.  That makes complete sense and I wish that I would’ve thought of that before.  This allows for a view controller to unload a view temporarily and insures that the IBOutlet objects are not leaked while doing so.

Hope this helps anyone else out there that was confused on the issue like I was.

Dec 02, 2009

Copyright © 2006-2026 Dennis Munsie.