Re: ARC and NSNib: How to release top-level objects?
Re: ARC and NSNib: How to release top-level objects?
- Subject: Re: ARC and NSNib: How to release top-level objects?
- From: Kyle Sluder <email@hidden>
- Date: Fri, 18 Nov 2011 14:05:55 -0800
On Fri, Nov 18, 2011 at 1:47 PM, Charles Srstka
<email@hidden> wrote:
> How is one supposed to manage this? You can easily get the array of the top-level objects, but since ARC doesn’t let you send -release to them, it doesn’t help much. The only ways I can think of to avoid leaking are to do silly things like performSelector:NSSelectorFromString(@“release”) or to wrap the NSNib-using code in a non-ARC source file. Neither seems ideal.
>
> What’s the best way to deal with something like this?
>From the recently-revised Resource Programming Guide:
"If the File’s Owner is not an instance of NSWindowController or
NSViewController, then you need to decrement the reference count of
the top level objects yourself. With manual reference counting, it was
possible to achieve this by sending top-level objects a release
message. You cannot do this with ARC. Instead, you cast references to
top-level objects to a Core Foundation type and use CFRelease. (If you
don’t want to have outlets to all top-level objects, you can use the
instantiateNibWithOwner:topLevelObjects: method of the NSNib class to
get an array of a nib file’s top-level objects.)"
http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW10
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden