• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController (From: Steve Mills <email@hidden>)

  • Prev by Date: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
  • Next by Date: Change NSCursor globally
  • Previous by thread: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
  • Next by thread: Re: View based NSTableView bounds to NSArrayController bounds to NSUserDefaultsController
  • Index(es):
    • Date
    • Thread