Re-reading my response, I hope it didn’t come across as snarky. If so, I 
apologize, as that wasn’t my intention.

Anyway, I believe that it is expected behavior that a tab view item is released 
when it is removed, and in non-ARC environments that tends to mean a lot of 
autoreleasing, and xib-loading semantics also muddy the water, so some memory 
issues can be hidden and only crop up in certain circumstances. One of the 
reasons for going ARC, I imagine. This could explain the difference, as well as 
possibly some sort of timing issue with how ARC disposes of objects, since the 
tab view item should be gone as well.

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Apr 4, 2019, at 9:29 AM, Casey McDermott <supp...@turtlesoft.com> wrote:
> 
> The tab view item has a strong reference to the view controller, but the 
> controller is released
> even though the tab view item still exists.  So, selecting the tab hits the 
> controller ref and it
> crashes with EXC_BAD_ACCESS.  My guess is it's released when the NSTabView
> switches views, but a breakpoint at dealloc doesn't help much.
> 
> However, we were not using a NSTabViewController.  We'll try that now.
> 
> Thanks,
> 
> Casey McDermott
> Turtle Creek Software 
> 
> --------------------------------------------
> On Thu, 4/4/19, Keary Suska <cocoa-...@esoteritech.com> wrote:
> 
> Subject: Re: NSTabViewItem and NSViewController
> To: "Casey McDermott" <supp...@turtlesoft.com>
> Cc: "Cocoa-Dev (Apple)" <cocoa-dev@lists.apple.com>
> Date: Thursday, April 4, 2019, 10:01 AM
> 
> Who owns the view controller?
> Apparently, no-one, sine ARC is deallocating it once the
> last reference to it (the tab view item) is deallocated. If
> there is supposed to be an owner, make sure the owner’s
> reference is strong. If you can target 10.10+, using
> NSTabViewController is probably a better choice.
> 
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or
> business"
> 
>> On Apr 4, 2019, at
> 7:43 AM, Casey McDermott <supp...@turtlesoft.com>
> wrote:
>> 
>> We have a
> tab view with tabs added from code.  Each tab uses a
> NSTabViewItem subclass,
>> which contains
> a reference to a NSViewController subclass within it to
> manage tab contents. 
>> Users click to
> add and remove tabs.
>> 
>> It works fine without ARC, with the
> NSTabView controlling the viewer lifetime.
>> With ARC, it works fine with one tab. 
> However the view controller is released and deallocated
>> when a second tab is added, so switching
> tabs causes a crash from the invalid reference.
>> 
>> Is there some way to
> see what is releasing the view controller?   It's
> nothing in our code.
>> NSTabView seems
> the likeliest culprit?
>> 
>> NSTabViewItem is not a NSView subclass.
> Does that prevent it from managing lifetime for a view and
> view controller?
>> 
>> 
> Thanks,
>> 
>> Casey
> McDermott
>> Turtle Creek Software
> 
>> 
> _______________________________________________
>> 
>> 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/cocoa-dev%40esoteritech.com
>> 
>> This email sent to
> cocoa-...@esoteritech.com
> 

_______________________________________________

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

Reply via email to