On Nov 17, 2008, at 11:35 PM, Roland King wrote:



Yes, but this is exactly the point. If I have no property for an Outlet it's still retained. If I have a property for an outlet that is assign, and not retain the outlet is still retained, and I still must release it, even though I never retained it.

When you say I can manage the outlets any way I like this is wrong. They are managed for me. I want them to not be retained. I don't have that option.

Now that I understand this I can live with it. But it still makes no sense to me.
_______________________________________________

That's not what the documentation says and it's not my experience either. The documentation says (section titled NIB Object Retention) that each object in the NIB file is created with a retain count of 1 and then autoreleased. Then they are hooked up using setValue:forKey: which uses the setter method if it exists. It also explicitly tells you that if you don't retain the array of top-level objects you're going to lose them.

So if you have an outlet which is assign, and the setter method is correct, the object will be created with retain count of 1, autoreleased, then the setter method will be called and assign it (no retain) and you do not have to release it. Why do you think that you do?

I've done this, I have this exact patten in some of my iPhone code, I have a delegate property which is assign and it is assigned and it goes away when it's supposed to go away.


OK. The reason I believe that is because I fixed a massive memory leak a couple days ago that I tracked down to this issue. I built a simple test application that demonstrates that outlets that have no properties or have assign properties are retained anyway and must be released.

Here's my test project:

http://bellsouthpwp2.net/b/r/brians99/projects/TestPropertiesAndOutlets.zip

There are three labels that are outlets. One has a retain property, one an assign property, and the third no property. Unless they are released they are never dealloced. All three act the same.

--
Brian Stern
[EMAIL PROTECTED]



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to