Re: Two Array Controllers, loading from CoreData, without a contentArray...
Re: Two Array Controllers, loading from CoreData, without a contentArray...
- Subject: Re: Two Array Controllers, loading from CoreData, without a contentArray...
- From: Jim Thomason <email@hidden>
- Date: Tue, 22 Sep 2015 17:51:35 -0500
My request was specifically about keeping two NSArrayControllers in sync
that are -not- bound to a content array.
The case I was tooling around with was for a root level object that just
fetches all of its data automatically and bypasses any contentArray binding.
Hypothetically, you could have whatever object is vending out the
contentArray check its value and see if it's nil. If it is, then fetch the
entities from the context using the specified fetch predicate. The
annoyance with this is that it'd require a link from the model object back
to the array controller, to learn which entities to fetch and with what
predicate.
I think I'd rather post the notification to the other array controller to
keep it all loosely coupled, if I had to choose between the two techniques.
-Jim...
On Tue, Sep 22, 2015 at 5:28 PM, Richard Charles <email@hidden>
wrote:
>
> > On Sep 22, 2015, at 7:40 AM, Jim Thomason <email@hidden> wrote:
> >
> > The question is simple - is there a reasonable way to create two
> > NSArrayControllers, have them bound to an entity through CoreData, and
> keep
> > them in sync?
>
> One way would be to bind the two array controllers to the same content
> array. The content array can be an array of managed objects. You may need a
> custom binding. Subclass and override -[NSArrayController remove:] to
> remove the selection from the managed object context. You may need to add
> objects to the managed object context through some other means as the array
> controller may not operate in entity mode without the content bound to a
> managed object context.
>
> This may help when trying to programmatically initialize the controller.
>
> http://stackoverflow.com/questions/1860805/nsarraycontroller-initialization
>
> Another neat thing you can do with NSArrayController is chain two of them
> together.
>
> http://www.informit.com/articles/article.aspx?p=1397563&seqNum=4
>
> It is amazing how versatile NSArrayController can be but you may need to
> work with it and try some experimenting.
>
> --Richard Charles
>
>
_______________________________________________
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