Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
- Subject: Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
- From: Keary Suska <email@hidden>
- Date: Mon, 06 Feb 2017 09:30:15 -0700
> On Feb 6, 2017, at 7:43 AM, Steve Mills <email@hidden> wrote:
>
> (Has cocoa-dev been down for days or what?)
>
> Why is it that most times when I implement a table, it can waste hours of my time?
>
> So I think I have everything set up like it should be. I'll just jump right to the bug and then we can work back. The problem is that when I edit values in the table, they only seem to get written to the defaults if I add a new item after editing an existing item.
>
> 1. Run app.
> 2. Edit existing row value.
> 3. Add new row and edit it.
> Result: Edited row is changed, new row has only default value instead of edited value.
>
> Any ideas?
Warning: the following explanation assumes a scenario that you don’t explicitly describe, namely that you are editing an array-type defaults value.
This is a known “issue”, if you want to call it that. As I understand it, the problem is that NSUserDefaultsController cannot "deep-observe” array-type defaults. I.e., it can watch the array itself for changes but not individual array elements because there is no clear key path to a specific array element. That is why you see changes when you alter the array itself (by adding/removing array elements), but not changes to the values of individual array elements. So, this is a limitation to the implementation of KVC/KVO, rather than any specific issue with NSUserDefaultsController.
The only way to handle this situation, IMHO, is to have some intermediary or user-driven event (like a “commit” button) that “tricks” the defaults controller into thinking the entire array has changed when you need to it see changes to individual elements.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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