refreshObject doesn't seem to work
refreshObject doesn't seem to work
- Subject: refreshObject doesn't seem to work
- From: Steve Steinitz <email@hidden>
- Date: Wed, 8 Oct 2008 23:02:18 +1100
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 (email@hidden)
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:
This email sent to email@hidden