Re: Bindings / Core Data: Ensuring a value is unique
Re: Bindings / Core Data: Ensuring a value is unique
- Subject: Re: Bindings / Core Data: Ensuring a value is unique
- From: "I. Savant" <email@hidden>
- Date: Thu, 14 Sep 2006 14:15:56 -0400
Chris:
First, you can have as many array controllers representing the
same entity as you want (within the limits of your system's
resources, of course). This is not a problem.
Second, be careful with your wording; it makes it far easier to
communicate when you use proper terminology. For example, "must
always return every entity" is a bit confusing. Rather, you want it
to provide you with every instance of its represented entity.
Third, nice ASCII drawing. :-D
Fourth, you need to tell the other controller to -fetch: when you
delete the object and that will cause it to update properly.
Fifth, regarding, "I would take as meaning it is not a 'nil'
value?", I'm not quite sure what you mean, but I'm pretty sure the
answer is "no" ... ;-)
Hope this helps. List, if I've misstated anything, please enlighten.
--
I.S.
On Sep 14, 2006, at 12:19 PM, Chris Blunt wrote:
Sorry, shadow copy probably isn't the best description...long day
staring at code :) Basically, I have two NSArrayControllers that
both look at the same entity (is this a bad thing to do?). The
reason being whilst one arraycontroller *might* have a contentSet
binding (depending on the user's selection), the other must always
return every entity in the object graph:
Entity A --------------------------------
Entity B |
Entity C --- |
Entity D | |--- NSArrayController 2 (All)
Entity E |---NSArrayController 1 |
Entity F | |
Entity G --- |
Entity H --------------------------------
Here, all entities are returned by NSArrayController(2), but only
entities DEFG are returned by NSArrayController(1). I hope this
makes sense!
Anyway, the problem occurs when deleting one of the entities from
either of those NSArrayControllers. Although it vanishes from the
(current) controller, the entity remains in the other controller.
It also doesn't appear to be a valid entry, as if I edit the
'shadow' entity in the other array controller, it is valid. I would
take as meaning it is not a 'nil' value?
Again, I'm not sure if having two controllers for the same data is
good practice, so please let me know if there is a better way to
tackle this problem!
Thanks,
Chris
--
www.chrisblunt.com
On 14 Sep 2006, at 16:52, I. Savant wrote:
You'll have to define "shadow copy".
I'm not sure if this is what you're seeing, but objects are not
immediately removed from the store when you delete them from a
context. Rather, they are marked as "deleted" and removed when the
store is saved. The Core Data Programming Guide explains this in
detail.
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
index.html
--
I.S.
On Sep 14, 2006, at 11:47 AM, Chris Blunt wrote:
I've got some strange behaviours appearing in my controllers now
as well - deleted records seem to leave a 'shadow' copy of the
record, despite multiple calls to [NSManagedObjectContext
processPendingChanges] and [NSArrayController prepareContent].
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden