Simperium on iOS not syncing data correctly

53 Views Asked by At

I'm testing data synchronization on 2 iPads logged in as the same Simperium user.

  • If I create an object named object1 on iPad1 it successfully synchronizes with iPad2.
  • If I create an object named object2 on iPad2 it successfully synchronizes with iPad1
  • If I modify object1 on iPad2 it successfully synchronizes with iPad1
  • If I modify object2 on iPad1 it successfully synchronizes with iPad2
  • If I modify object1 on iPad1 it DOES NOT synchronize the change with iPad2 although it does push the change to Simperium's data store
  • If I modify object2 on iPad2 it DOES NOT synchronize the change with iPad1 although it does push the change to Simperium's data store

I was running Simperium 0.8.3. I just updated to Simperium 0.8.12 and the problem still exists.

What can I do to troubleshoot this issue? Is this a bug?

1

There are 1 best solutions below

0
Victor On

I think I figured it out. I had a method that I created that added an object to Core Data and wrote nil values for any data not supplied. For example:

+(BOOL) addActivity:(NSNumber *)identifier item_id:(NSNumber *)item_id  {

    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    NSManagedObjectContext *context = appDelegate.managedObjectContext;

    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Activity" inManagedObjectContext:context];
    Activity *a = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
    [a setValue:identifier forKey:@"id"];
    [a setValue:item_id forKey:@"item_id"];

    // Save the context.
    NSError *error = nil;
    if (![context save:&error]) {

        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);

        return NO;

    } else {

        return YES;
    }

    return NO;
}

Apparently SPDiffer doesn't like this since it kept on throwing errors like:

transform diff for a ghost member (ghost <SPGhost: 0x7fba9617dae0>, memberData {
    <data>
}) that doesn't exist (item_id): {
    o = "+";
    v = 0;
}

when item_id does exist, except it had a nil value written so SPDiffer couldn't tell the type. I added some if statements to my code so I don't write nil values and just ignore that field.

if (item_id) {
    [a setValue:item_id forKey:@"item_id"];
}

I hope this makes sense and helps someone else out.