Re: Arraycontroller and CoreData
Re: Arraycontroller and CoreData
- Subject: Re: Arraycontroller and CoreData
- From: Keary Suska <email@hidden>
- Date: Thu, 12 Sep 2013 10:37:57 -0600
On Sep 12, 2013, at 9:11 AM, Benjamin Rindt wrote:
> I'm really confused with the array controller and core data. I don't know what I have to use to get what I want.
> My program has for now a CollectionView which is populated by a core data fetch request.
>
> If I use an arrayController, I don't have to make this fetch do I? I can tell the array controller to fetch: ?
You don't even need to call -fetch: in most cases--the array controller can fetch itself when automaticallyPreparesContent is set.
> Next thing is, when new Items are added to the collection view, it should automatically change.
> A binding of the collection view is enough? Something like [collectionview bind: toObject:….]
Not in your case. There is no way I can think of via pure KVO that the array controller would know that its fetched set may have changed. It might if you use NSArrayController's methods to add/remove objects, and if so you would also get undo support for free, but I don't remember whether it works for fetched results (works really well for relationships).
> And, for now I add data to my core data database with insertNewObjectForEntityForName. Is that okay or should I add it with the array controller's add oder insertObject methods? The new entries have to keep their relationships and I don't know how I can define them with the array controller methods.
You could try using NSArrayController's methods, and if that doesn't work, then you need to tell the array controller to refetch whenever items are added/removed, either in the add/remove methods or similar in an NSArray subclass.
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