Re: NSArrayController - error inserting object at arranged object index N
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: Fri, 24 Jun 2016 11:12:36 +0100
> On 23 Jun 2016, at 23:03, Quincey Morris <email@hidden> wrote:
>
> On Jun 23, 2016, at 13:39 , Jonathan Mitchell <email@hidden <mailto:email@hidden>> wrote:
>>
>> Do you mean something like this?
>> NSMutableArray *proxy = [NSArrayController mutableArrayValueForKey:@"content"];
>
> That wasn’t what I had in mind. I meant that you would make the array a property of a real model object, and update *that* property, without referring to the array controller directly at all. If you do a KVO compliant update under those circumstances, the array controller will get a KVO notification and update its internal state automatically. You shouldn’t need to re-filter manually.
>
Okay. I see what you mean now.
Yes - I think that would work.
The downside would be having to implement the compliant accessor methods in the real model object (in my case the array is a constructed property of an NSViewController subclass which obtains its array data from a non native Obj-C model)
This would be beneficial if the array property was also being observed externally.
My usage case scenario is mainly bindings based and so the NSArrayController provides an effective and concise means of providing a KVO compliant to-many property to the likes of NSTableView etc. I think this is the essence point you were making about using NSArrayControllers in code previously. I find them hugely useful for UI related bindings. Outside of that their utility is less obvious.
Thanks for taking the time and effort to respond to this - i definitely improved my knowledge by thinking about your points.
KVO compliance for to-many properties was always something I was a bit wooly about and I suspect that many others will be too,
IMHO getting to grips with this is one of the most difficult aspects of AppKit.
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