Permalink
Browse files

RKSyncObserver doesn't save the objectStore anymore; this should be d…

…one by the user so that objects that require relationships don't fail validations.
  • Loading branch information...
1 parent 7d0f3e7 commit d446ed4c3a6890a87d0f8f3b0fe6c8913027efcf @ecordell committed Jul 27, 2011
Showing with 8 additions and 13 deletions.
  1. +4 −4 Code/CoreData/RKManagedObjectSyncObserver.h
  2. +4 −9 Code/CoreData/RKManagedObjectSyncObserver.m
@@ -138,31 +138,31 @@ typedef enum {
* @param object The NSManagedObject to modify
* @param error An error reference to pass back saving errors
*/
-- (void)shouldNotSyncObject:(NSManagedObject*)object error:(NSError**)error;
+- (void)shouldNotSyncObject:(NSManagedObject*)object;
/**
* Sets the _rkManagedObjectSyncStatus on the object to RKSyncStatusShouldPost
* If autosyncing, and network access is available, passes object directly to the objectManager
* @param object The NSManagedObject to modify
* @param error An error reference to pass back saving errors
*/
-- (void)shouldPostObject:(NSManagedObject*)object error:(NSError**)error;
+- (void)shouldPostObject:(NSManagedObject*)object;
/**
* Sets the _rkManagedObjectSyncStatus on the object to RKSyncStatusShouldPut
* If autosyncing, and network access is available, passes object directly to the objectManager
* @param object The NSManagedObject to modify
* @param error An error reference to pass back saving errors
*/
-- (void)shouldPutObject:(NSManagedObject*)object error:(NSError**)error;
+- (void)shouldPutObject:(NSManagedObject*)object;
/**
* Sets the _rkManagedObjectSyncStatus on the object to RKSyncStatusShouldDelete
* If autosyncing, and network access is available, passes object directly to the objectManager
* @param object The NSManagedObject to modify
* @param error An error reference to pass back saving errors
*/
-- (void)shouldDeleteObject:(NSManagedObject*)object error:(NSError**)error;
+- (void)shouldDeleteObject:(NSManagedObject*)object;
@end
@@ -130,48 +130,43 @@ - (void) syncWithDelegate: (NSObject<RKManagedObjectSyncDelegate>*)delegate {
#pragma mark - Sync Management
-- (void)shouldNotSyncObject:(NSManagedObject*)object error:(NSError**)error {
+- (void)shouldNotSyncObject:(NSManagedObject*)object {
object._rkManagedObjectSyncStatus = [NSNumber numberWithInt:RKSyncStatusShouldNotSync];
- *error = [[[RKObjectManager sharedManager] objectStore] save];
}
-- (void)shouldPostObject:(NSManagedObject*)object error:(NSError**)error {
+- (void)shouldPostObject:(NSManagedObject*)object {
if (_isOnline && _shouldAutoSync) {
[[RKObjectManager sharedManager] postObject:object delegate:self];
} else {
if ([object._rkManagedObjectSyncStatus intValue] == RKSyncStatusShouldNotSync ||
[object._rkManagedObjectSyncStatus intValue] == RKSyncStatusShouldPost) {
object._rkManagedObjectSyncStatus = [NSNumber numberWithInt:RKSyncStatusShouldPost];
- *error = [[[RKObjectManager sharedManager] objectStore] save];
} else {
RKLogError(@"Trying to post an object that exists on the server.");
}
}
}
-- (void)shouldPutObject:(NSManagedObject*)object error:(NSError**)error {
+- (void)shouldPutObject:(NSManagedObject*)object {
if (_isOnline && _shouldAutoSync) {
[[RKObjectManager sharedManager] putObject:object delegate:self];
} else {
//if set to post already, we want to just change the data the will be posted, not switch to a put
if ([object._rkManagedObjectSyncStatus intValue] != RKSyncStatusShouldPost) {
object._rkManagedObjectSyncStatus = [NSNumber numberWithInt:RKSyncStatusShouldPut];
- *error = [[[RKObjectManager sharedManager] objectStore] save];
}
}
}
-- (void)shouldDeleteObject:(NSManagedObject*)object error:(NSError**)error {
+- (void)shouldDeleteObject:(NSManagedObject*)object {
if (_isOnline && _shouldAutoSync) {
[[RKObjectManager sharedManager] deleteObject:object delegate:self];
} else {
if ([object._rkManagedObjectSyncStatus intValue] == RKSyncStatusShouldPost) {
//if deleting an object that hasn't been posted yet, just delete it locally
[object deleteEntity];
- *error = [[[RKObjectManager sharedManager] objectStore] save];
} else {
object._rkManagedObjectSyncStatus = [NSNumber numberWithInt:RKSyncStatusShouldDelete];
- *error = [[[RKObjectManager sharedManager] objectStore] save];
}
}
}

0 comments on commit d446ed4

Please sign in to comment.