Re: Success with NSTableView weak delegates?

2016-09-20 Thread Sean McBride
On Tue, 20 Sep 2016 16:41:07 -0700, Greg Parker said:

>Those crashes are expected. 
>
>NSTableView's delegate is zeroing-weak when both of the following are true:
>* Your app was built with the 10.11 SDK or newer.
>* Your app is running on 10.12 or newer.
>
>The delegate is unsafe-unretained when running on 10.11 and earlier, no
>matter what SDK you built with.

Ah ha, thanks!  That WWDC video is quite misleading then.  I was about to 
lament the lack of any better docs, but now realize that it's actually nicely 
documented here in the 10.12 release notes:


So sorry for the noise!

Thanks David & Greg!

Cheers,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada



___

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

Re: Success with NSTableView weak delegates?

2016-09-20 Thread Greg Parker

> On Sep 20, 2016, at 2:47 PM, Sean McBride  wrote:
> 
> On Tue, 20 Sep 2016 14:26:27 -0700, David Duncan said:
> 
>>> On Sep 20, 2016, at 1:21 PM, Sean McBride  wrote:
>>> 
>>> Hi all,
>>> 
>>> WWDC 2016 Session 203 "What's New in Cocoa" at around 43:37 in the
>>> video, says that if you link against the 10.11 SDK that NSTableView's
>>> delegate is weak.  So I went and wrapped my delegate nil-ing in:
>>> 
>>> #if MAC_OS_X_VERSION_MAX_ALLOWED < 101100
>>> [tableView setDelegate:nil];
>>> [tableView setDataSource:nil];
>>> #endif
>>> 
>>> yet (with NSZombie especially), I easily reproduce message-to-zombie
>>> crashes with builds that are made against the Xcode 7.3.1 10.11 SDK.
>> 
>> On which OS version?
> 
> At runtime: 10.9.5, 10.10.5, and 10.11.6.
> 
>> The macro above only says “do this if I link against an SDK prior to
>> 10.11” – that doesn’t handle what happens at runtime when you are on
>> 10.10 or below. In particular, if you plan to deploy back to prior to
>> 10.11, then you would want to either do a runtime check, or for trivial
>> code like this always run the code until your MIN_ALLOWED (deployment
>> target) is >= 10.11.
> 
> Yes, I'm aware of these differences.  I'm also aware, as you surely are, that 
> sometimes behaviour depends (only) on what SDK you link against.
> 
> If you scrub to around 43:37 here:
> 
> 
> you'll see they specifically refer to "linked on 10.11".
> 
> Besides, I both build and run on 10.11.6 and yet I see these 
> message-to-zombie crashes after removing the setDelegate:nil code.

Those crashes are expected. 

NSTableView's delegate is zeroing-weak when both of the following are true:
* Your app was built with the 10.11 SDK or newer.
* Your app is running on 10.12 or newer.

The delegate is unsafe-unretained when running on 10.11 and earlier, no matter 
what SDK you built with.


-- 
Greg Parker gpar...@apple.com  Runtime 
Wrangler


___

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

Re: Success with NSTableView weak delegates?

2016-09-20 Thread David Duncan

> On Sep 20, 2016, at 2:47 PM, Sean McBride  wrote:
> 
> On Tue, 20 Sep 2016 14:26:27 -0700, David Duncan said:
> 
>>> On Sep 20, 2016, at 1:21 PM, Sean McBride  wrote:
>>> 
>>> Hi all,
>>> 
>>> WWDC 2016 Session 203 "What's New in Cocoa" at around 43:37 in the
>> video, says that if you link against the 10.11 SDK that NSTableView's
>> delegate is weak.  So I went and wrapped my delegate nil-ing in:
>>> 
>>> #if MAC_OS_X_VERSION_MAX_ALLOWED < 101100
>>> [tableView setDelegate:nil];
>>> [tableView setDataSource:nil];
>>> #endif
>>> 
>>> yet (with NSZombie especially), I easily reproduce message-to-zombie
>> crashes with builds that are made against the Xcode 7.3.1 10.11 SDK.
>> 
>> On which OS version?
> 
> At runtime: 10.9.5, 10.10.5, and 10.11.6.
> 
>> The macro above only says “do this if I link against an SDK prior to
>> 10.11” – that doesn’t handle what happens at runtime when you are on
>> 10.10 or below. In particular, if you plan to deploy back to prior to
>> 10.11, then you would want to either do a runtime check, or for trivial
>> code like this always run the code until your MIN_ALLOWED (deployment
>> target) is >= 10.11.
> 
> Yes, I'm aware of these differences.  I'm also aware, as you surely are, that 
> sometimes behaviour depends (only) on what SDK you link against.

Sure, but that generally only applies to that OS or later, as we cannot 
generally change the behavior of older OSes (there are specific recent 
exceptions to that, but they are typically fairly low level and targeted). I 
don’t think the speaker here was trying to imply that this feature was 
available prior to 10.11.

> Besides, I both build and run on 10.11.6 and yet I see these 
> message-to-zombie crashes after removing the setDelegate:nil code.

Thats pretty much what I was trying to verify, and so this sounds like this is 
a bug somewhere. I would highly recommend filing it.
--
David Duncan

___

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

Re: Success with NSTableView weak delegates?

2016-09-20 Thread Sean McBride
On Tue, 20 Sep 2016 14:26:27 -0700, David Duncan said:

>> On Sep 20, 2016, at 1:21 PM, Sean McBride  wrote:
>> 
>> Hi all,
>> 
>> WWDC 2016 Session 203 "What's New in Cocoa" at around 43:37 in the
>video, says that if you link against the 10.11 SDK that NSTableView's
>delegate is weak.  So I went and wrapped my delegate nil-ing in:
>> 
>> #if MAC_OS_X_VERSION_MAX_ALLOWED < 101100
>>  [tableView setDelegate:nil];
>>  [tableView setDataSource:nil];
>> #endif
>> 
>> yet (with NSZombie especially), I easily reproduce message-to-zombie
>crashes with builds that are made against the Xcode 7.3.1 10.11 SDK.
>
>On which OS version?

At runtime: 10.9.5, 10.10.5, and 10.11.6.

>The macro above only says “do this if I link against an SDK prior to
>10.11” – that doesn’t handle what happens at runtime when you are on
>10.10 or below. In particular, if you plan to deploy back to prior to
>10.11, then you would want to either do a runtime check, or for trivial
>code like this always run the code until your MIN_ALLOWED (deployment
>target) is >= 10.11.

Yes, I'm aware of these differences.  I'm also aware, as you surely are, that 
sometimes behaviour depends (only) on what SDK you link against.

If you scrub to around 43:37 here:


you'll see they specifically refer to "linked on 10.11".

Besides, I both build and run on 10.11.6 and yet I see these message-to-zombie 
crashes after removing the setDelegate:nil code.

Cheers,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada

___

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

Re: Success with NSTableView weak delegates?

2016-09-20 Thread David Duncan

> On Sep 20, 2016, at 1:21 PM, Sean McBride  wrote:
> 
> Hi all,
> 
> WWDC 2016 Session 203 "What's New in Cocoa" at around 43:37 in the video, 
> says that if you link against the 10.11 SDK that NSTableView's delegate is 
> weak.  So I went and wrapped my delegate nil-ing in:
> 
> #if MAC_OS_X_VERSION_MAX_ALLOWED < 101100
>   [tableView setDelegate:nil];
>   [tableView setDataSource:nil];
> #endif
> 
> yet (with NSZombie especially), I easily reproduce message-to-zombie crashes 
> with builds that are made against the Xcode 7.3.1 10.11 SDK.

On which OS version?

The macro above only says “do this if I link against an SDK prior to 10.11” – 
that doesn’t handle what happens at runtime when you are on 10.10 or below. In 
particular, if you plan to deploy back to prior to 10.11, then you would want 
to either do a runtime check, or for trivial code like this always run the code 
until your MIN_ALLOWED (deployment target) is >= 10.11.

> 
> Anyone have success with these supposedly weak tableview delegates?
> 
> Thanks,
> 
> -- 
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com 
> Mac Software Developer  Montréal, Québec, Canada
> 
> 
> 
> ___
> 
> 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/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

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