Re: NSTableView update issue
Re: NSTableView update issue
- Subject: Re: NSTableView update issue
- From: Ken Thomases <email@hidden>
- Date: Sat, 26 Sep 2015 05:43:02 -0500
On Sep 26, 2015, at 5:13 AM, Peter Hudson <email@hidden> wrote:
> I have an NSTableView in my app which has started to behave differently on 10.10.
>
> I periodically change the datasource and delegate to the table view ( which is on screen )
> This has worked perfectly up until recently.
>
>
> After having changed the datasource/delegate to the table view, I confirm that the table view is aware of the change - by use of delegate and dataSource methods. The result from this indicates that the table view has had its datasource and delegate updated as I intended.
>
> I then reloadData and display the table view. Results are as expected.
>
> A short period after, the app will crash. Zombies tells me that the table view is accessing the previously set datasource for data - not the one that I have just installed ( and confirmed as being the data source ).
Show the stack trace of the access to the zombie.
Remember that, normally, a view-based table view's delegate is used as the owner for the NIB for cell views and row views. Such views persist. Some are presumably being displayed and others may be in the reuse queue. I would not expect that changing the table view's delegate would alter that because there's no good way to do so. The table view can't know what connections may have been established by the NIB when it was loaded. (Connections to the NIB's owner would be those to the File's Owner placeholder. If your cell views or row views are designed in the same NIB as the table view itself then you may have been mislead. It's not obvious but such views are actually in sub-NIBs encoded into the outer NIB. Connections to the File's Owner placeholder from objects outside of the table columns end up connecting to the owner of the outer NIB. Connections to the File's Owner placeholder from objects inside the table columns end up connecting to the table view's delegate.)
Frankly, I don't think it's a good idea to do this switching like you're doing. Just have the delegate and data source switch their behavior as appropriate. Or swap entire table views in and out.
Regards,
Ken
_______________________________________________
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