• 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
Core Data: Save As workflow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data: Save As workflow


  • Subject: Core Data: Save As workflow
  • From: Pierre Bernard <email@hidden>
  • Date: Tue, 25 Apr 2006 22:30:12 +0200

Hi!

I am wondering what happens exactly when a Core Data document is saved to an new location.

Let's say I start with an existing document. As it is loaded objects are fetched into memory. Objects are held in controllers and bound to view elements.

Now I save the document to a new location. As a new file is created, I _guess_ an new persistent store is created. That would imply swapping out the whole persistence stack.

Somehow the object graph then has to be migrated to or recreated in the new managed object context. I just can't imagine how that could go about. Controllers and views have references to managed objects. Thus creating the objects afresh seems impraticable. But can objects be migrated to a new object store?

Seeing that I occasionally see the following error after saving a document, I got the understanding that migrating is not possible. "Can’t reassign an object to a different store oncebeen saved. "

Now I am confused.

The reason I am asking is of course that I have a problem to solve.

Upon 2 successive save-as operations on my document based applications I am seeing debug messages like the one below:

2006-04-25 06:40:41.966 HoudahSpot[3627] Cocoa Bindings: Error accessing value for key path selection.queryAttribute of object <NSObjectController: 0x5a545c0>[entity: QueryItem] (from bound object <NSPopUpButton: 0x5a47610>): [<QueryLeaf 0x3aa470> valueForUndefinedKey:]: this class is not key value coding-compliant for the key queryAttribute.

The odd thing is that QueryLeaf does have a queryAttribute attribute and all works fine until those 2 "Save as" operations.

I guess the object is incorrectly recreated in the new object store.

The involved NSManagedObject sub-classes are:

_QueryItem <- QueryItem <- _QueryLeaf <- QueryLeaf
_QueryItem <- QueryItem <- _QueryNode <- QueryNode

For debugging purposes I added this to QueryLeaf.m:

- (id)valueForUndefinedKey:(NSString *)key
{
	NSLog(@"key: %@", key);

	if ([self respondsToSelector:NSSelectorFromString(key)]) {
		NSLog(@"self: %@", self);
	}

	return [super valueForUndefinedKey:key];
}

It appears that the key does actually exist in the object. Calling the accessor method from here causes an infinite loop. I suspect the problem to be triggered within primitiveValueForKey:.

The print-out from the above method reads:

2006-04-25 06:40:41.964 HoudahSpot[3627] key: queryAttribute
2006-04-25 06:40:41.965 HoudahSpot[3627] self: <QueryLeaf: 0x3aa470> (entity: (null); id: 0x5a452b0 <(null)> ; data: {})


The "entity: (null);" part seems odd for a NSManagedObject.

I guess the object with no entity was created during the data migration to the new object store. Or is it a left-over of the old?


Information and thoughts appreciated

Pierre

_______________________________________________
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


  • Follow-Ups:
    • Re: Core Data: Save As workflow
      • From: Greg Herlihy <email@hidden>
  • Prev by Date: Re: Calling `update_prebinding' programmatically
  • Next by Date: bad mouse with NSComboBox on sheet
  • Previous by thread: Programmatic bindings question
  • Next by thread: Re: Core Data: Save As workflow
  • Index(es):
    • Date
    • Thread