What I'm trying to do is to allow users to create files and add those files into a user support folder so that their other files can inherit features of that document. Essentially, I'm trying to allow inheritance in my files.

I was trying to adapt the iClass sample code to work in a document- based form. The iClass example works great if you have the file saved at runtime, but in documents they aren't saved right away. I haven't been successful in migrating the document from an internal private store into the public document store.

I took out the step where I would try to link between two files yet, as that would add another kink in the works.

So, what I've done is taken my NSManagedObject class and had it check to see if it needed to update after save to have a permanent objectID.

@implementation MyManagedObject
...
- (void)didSave
{
        //set core data URI so it can be pulled back up when it is reloaded
...
[self setRelationshipURI:[[[relationshipObject objectID] URIRepresentation] description] ];
        [[self managedObjectContext] save:&error] ;
        //Causes duplicate entries in the file:
        //<z101>
        //<z102>
        //<z101>
        //<z102> <URI>
}
...
@end

Andy Finnell's post on multithreading and cocoa seems like a similar problem to what I am experiencing, but everything is on the main thread. I decided to set my merge policy to NSMergeByPropertyObjectTrumpMergePolicy anyway.

Could it be due to bindings? I have an NSTreeController and an NSArrayController that both manage the objects at a hierarchal and flat level. I ruled that out due to nothing being wrong with the in- memory context.

Finally, I tested what happened when I open one of these files, and it opens the most recent version of the object twice. I can't figure out how to stop the duplicates being stored before it is saved.

I hope this is more fine-grained to get some help on this issue. I'd love to get this working and share the solution.

On Jan 22, 2009, at 11:06 PM, Quincey Morris wrote:

On Jan 21, 2009, at 13:15, Derek Kuhl wrote:

        I created a document-based core data application and want it to be
able to add external files from a support folder.  I can
successfully set the permanent URIs for the transient relationships
working in memory, but for some reason saving to file never works
properly.  If I tell each object to save the context using save: in
the didSave: method, it will save a duplicate in the file.  If I try
to save the context in the document's document:didSave:contextInfo:
method mentioned in the documentation, it works again but doesn't
save.  Thank you in advance for any information someone has on what
I'm doing wrong.

Did you get any responses to this and/or are you still having a problem?

If you're still looking for assistance, you're going to have to spell
things out a bit more clearly. Are the external files persistent
stores you add to the persistent store controller, or are they just
additional files you keep references to as property values? If you
have information in transient properties, why are you expecting those
values to be saved at all? What kind of context are you talking about?
If you mean managed object context, why are you telling objects to
"save" it? Etc.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to