On Oct 16, 2013, at 16:39:04, Charles Srstka <cocoa...@charlessoft.com> wrote:
> Aha, that definitely explains the leaks you've been getting. The trouble with > instantiateWithOwner:, and the reason it's been deprecated, is because it > doesn't follow the standard Cocoa memory management rules. Specifically, it > retains the top-level objects, and leaves it your responsibility to release > them, even though you never alloced, copied them, or retained them. There are > three ways to deal with this: > > 1. Have an outlet to each top-level object in the nib, and make sure to > release them all when your object deallocates. > > 2. Store the array returned as the second parameter of > -instantiateWithOwner:topLevelObjects:, and when your object deallocates, > loop through the array and release everything. > > 3. (This is the one I'd recommend) Instead of using NSNib, make a subclass of > NSWindowController (if your nib defines a window) or NSViewController (if > your nib defines a view). Then use either -[NSWindowController > initWithWindowNibName:] or -[NSViewController initWithNibName:bundle:] to > load the nib. This will produce correct behavior on any version of OS X, > including 10.7, and gives you a few other niceties as well. Great! Thanks for this valuable info. I'll look into it tomorrow. -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com