Hello,

We use Core Data for a multi-user, multi-machine point-of-sale system in a bicycle shop. When someone sells a bike on one machine the other machines don't immediately see it. I've tried everything I can think of, short of resetting the managedObjectContext to refresh the bike and its related sale -- all to no avail. Well, tantalizingly, occasionally the refresh works. I'm starting to wonder if refreshObject has a bug.

I've 'enhanced' refreshObject to, among other things, temporarily ignore the staleness interval:

    BOOL        mergeChanges    = YES;
    double stalenessInterval    = [context stalenessInterval];
    [context setStalenessInterval: 1];
    id currentMergePolicy = [context mergePolicy];
    [context setMergePolicy: NSMergeByPropertyStoreTrumpMergePolicy];
    if (nil != object)
    {
        [context processPendingChanges];
        @try
        {
            [context refreshObject: object mergeChanges: mergeChanges];
...

My refresh process:

1.  re-fetch all the relevant managedObjects (arrayController fetch)
2. call the above refreshObject on all of today's sales, every bike-mold (a sort of bike template) and every bike

the bike's sold status doesn't change nor does the relevant sale -- well, usually not.

I get optimistic locking errors on the first try at the above process but not on subsequent tries. I thought doing refreshObject would avoid optimistic locking errors but it appears not which experiments with detectConflictsForObject confirm.

I've spent time staring at the debug display of the generated SQL in xCode but it hasn't suggested any obvious action. I've been working on this on and off for months and have run out of ideas. (mmalc, I've read the docs 'til my eyes bled.) Except for this, the app works really well.

Thanks for any inspiration,

Steve

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to