• 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: NSArrayController - error inserting object at arranged object index N
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArrayController - error inserting object at arranged object index N


  • Subject: Re: NSArrayController - error inserting object at arranged object index N
  • From: Jonathan Mitchell <email@hidden>
  • Date: Thu, 23 Jun 2016 21:39:08 +0100

> On 23 Jun 2016, at 17:51, Quincey Morris <email@hidden> wrote:
>
>
>> My workaround was to set controller.clearsFilterPredicateOnInsertion == YES and reset the filterPredicate following -addObject:
>>
>> It might be possible to subclass NSArrayController …
>
> There’s no need to work around at all. The correct, straightforward solution is to update the content array (i.e. the unfiltered objects being managed via the array controller) directly in a KVO compliant manner, using ‘mutableArrayValueForKey:’.
>

Do you mean something like this?

NSMutableArray *proxy = [NSArrayController mutableArrayValueForKey:@"content"];
[proxy addObject:object];
[proxy filterUsingPredicate:self.filterPredicate];

This does work but is very slow even with a small collection (the subclass returned is an instance of NSKeyValueSlowMutableArray).
Perhaps NSArrayController does not override all the required KVC  methods for the content key?

[self.submissionsArrayController addObject:object];
self.submissionsArrayController.filterPredicate = self.filterPredicate;

The above amounts to the same thing and seems much more performant.

I suppose I could make my NSViewController class KVC compliant for the content array but that seems overkill in this case.

Thanks

J


_______________________________________________

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


  • Follow-Ups:
    • Re: NSArrayController - error inserting object at arranged object index N
      • From: Quincey Morris <email@hidden>
References: 
 >NSArrayController - error inserting object at arranged object index N (From: Jonathan Mitchell <email@hidden>)
 >Re: NSArrayController - error inserting object at arranged object index N (From: Jonathan Mitchell <email@hidden>)
 >Re: NSArrayController - error inserting object at arranged object index N (From: Quincey Morris <email@hidden>)

  • Prev by Date: unnamed function586 $$ AMDRadeon X4000GLDriver
  • Next by Date: Re: unnamed function586 $$ AMDRadeon X4000GLDriver
  • Previous by thread: Re: NSArrayController - error inserting object at arranged object index N
  • Next by thread: Re: NSArrayController - error inserting object at arranged object index N
  • Index(es):
    • Date
    • Thread