• 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: Bindings / Core Data: Ensuring a value is unique
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings / Core Data: Ensuring a value is unique


  • Subject: Re: Bindings / Core Data: Ensuring a value is unique
  • From: Chris Blunt <email@hidden>
  • Date: Fri, 15 Sep 2006 10:50:13 +0100

Thanks for your comments :) Unfortunately, I'm still having no luck when using fetch:. This is the code I have, where arrayControllerA, arrayControllerB and arrayControllerC are all instances of MyArrayController.


In MyArrayController.m:

- (IBAction)remove:(id)sender
{
	[super remove:sender];
	[documentController synchroniseArrayControllers];
}


In MyDocument.m:

- (void)synchroniseArrayControllers
{
	[[self managedObjectContext] processPendingChanges];

	[arrayControllerA fetch:self];
	[arrayControllerB fetch:self];
	[arrayControllerC fetch:self];
}

On your fifth point, what I meant was that the 'leftover' entity instance does exist in the object graph, so it's not the result of an NSTableView being out of sync with the controller. I've proven this by saving and reloading the data, complete with the leftover entity intact.

It seems, however, that the behaviour gets even stranger...Deleting entities now seems to reset their attributes to their initial values rather than deleting them. I think my best plan is to rebuild all the bindings and controllers in my app (read: 'start from scratch'). Luckily, this is only early days.

Thanks for your help though, I'll post back anything I can find out. I only hope bindings/core-data is easier to debug in XCode 3.0...!

Chris
--
www.chrisblunt.com


On 14 Sep 2006, at 19:15, I. Savant wrote:

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
References: 
 >Bindings / Core Data: Ensuring a value is unique (From: Chris Blunt <email@hidden>)
 >Re: Bindings / Core Data: Ensuring a value is unique (From: "I. Savant" <email@hidden>)
 >Re: Bindings / Core Data: Ensuring a value is unique (From: Chris Blunt <email@hidden>)
 >Re: Bindings / Core Data: Ensuring a value is unique (From: "I. Savant" <email@hidden>)
 >Re: Bindings / Core Data: Ensuring a value is unique (From: Chris Blunt <email@hidden>)
 >Re: Bindings / Core Data: Ensuring a value is unique (From: "I. Savant" <email@hidden>)

  • Prev by Date: Re: String in NSRect
  • Next by Date: Re: SystemUIMode
  • Previous by thread: Re: Bindings / Core Data: Ensuring a value is unique
  • Next by thread: Dialog problem
  • Index(es):
    • Date
    • Thread