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 12-23-2008, 01:05 PM   #2 (permalink)
airsource
Airsource Ltd
 
Join Date: Nov 2008
Location: Cambridge, UK
Posts: 3
Default Need to release if no property set.

Quote:
Originally Posted by jeff_lamarche View Post
Historically speaking, when working with IBOutlets on the Mac, you didn't retain the outlets in your controller class. There's an exception to this in that the root objects in the nib (the ones with an icon in the nib's main window) have to be released since they get created with a retain count of 1, but that is handled for us by the generic controller classes like WindowController, so in most situations, releasing IBOutlets simply wasn't necessary.

However, with the iPhone sample code, I've noticed that they've started declaring properties for the IBOutlets and also releasing the IBOutlets in the Dealloc. I wanted to ask about this change on Cocoa-dev, but the newer Cocoa sample code uses garbage collection, meaning it's only relevant to the iPhone SDK, so I'm sure I'd of gotten slapped down for asking about NDA stuff.

Anyway, here's my guess about what's happening, but haven't been able to confirm this in the documentation:

If you create a property or manually create KVC-compliant accessors and mutators, Interface Builder will use those mutator methods to assign objects to your IBOutlet. If you do not, then it will assign them directly to the instance variable. In the former case, if the mutator sends the object a retain or if you specified the optional retain attribute to our property (Apple does in their sample code), it is then necessary to release the object in your dealloc method.

Does this sound logical or right? Has anybody found a way to confirm or deny this information in the official documentation?

Thanks,
Jeff
Nearly - the direct assignation case does an retain as well. See
The Airsource - Memory Management and NIBS which has references to the relevant parts of the documentation.
airsource is offline   Reply With Quote
 

» Advertisements
» Online Users: 679
16 members and 663 guests
chits12345, ckgni, dana0550, Dani77, Domele, drewrico, handmachine, Harisstimolth5, JamesCahall, Janyeok, mistergreen2011, Monstertaco, noobAppDeveloper, Oral B, rimap123, salehamahbub
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,791
Threads: 89,205
Posts: 380,604
Top Poster: BrianSlick (7,129)
Welcome to our newest member, salehamahbub
Powered by vBadvanced CMPS v3.1.0

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