@@ -927,7 +927,7 @@ - (NSDictionary *)RESTDictionaryWithObjectEncoder:(PFEncoder *)objectEncoder
927927 return result;
928928}
929929
930- - (void )mergeFromRESTDictionary : (NSDictionary *)object withDecoder : (PFDecoder *)decoder {
930+ - (BOOL )mergeFromRESTDictionary : (NSDictionary *)object withDecoder : (PFDecoder *)decoder error : ( NSError **) error {
931931 @synchronized (lock) {
932932 BOOL mergeServerData = NO ;
933933
@@ -942,6 +942,8 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
942942 } else if (!state.updatedAt ) {
943943 mergeServerData = YES ;
944944 }
945+ __block BOOL hasFailed = NO ;
946+ __block NSError * remoteOpSetError = nil ;
945947 [object enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) {
946948 if ([key isEqualToString: PFObjectOperationsRESTKey]) {
947949 PFOperationSet *remoteOperationSet = nil ;
@@ -985,7 +987,13 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
985987 [localOperationSet.updatedAt compare: remoteOperationSet.updatedAt] != NSOrderedAscending) {
986988 [localOperationSet mergeOperationSet: remoteOperationSet];
987989 } else {
988- PFConsistencyAssert (remoteOperationSet, @" 'remoteOperationSet' should not be nil." );
990+ if (!remoteOperationSet) {
991+ NSString *message = [NSString stringWithFormat: @" 'remoteOperationSet' should not be nil in object of class %@ " , self .parseClassName];
992+ remoteOpSetError = [PFErrorUtilities errorWithCode: -1 message: message];
993+ hasFailed = YES ;
994+ *stop = YES ;
995+ return ;
996+ }
989997 NSUInteger index = [operationSetQueue indexOfObject: localOperationSet];
990998 [remoteOperationSet mergeOperationSet: localOperationSet];
991999 operationSetQueue[index] = remoteOperationSet;
@@ -1037,6 +1045,10 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
10371045 id decodedObject = [decoder decodeObject: obj];
10381046 [state setServerDataObject: decodedObject forKey: key];
10391047 }];
1048+ if (hasFailed && error) {
1049+ *error = remoteOpSetError;
1050+ return NO ;
1051+ }
10401052 if (state.updatedAt == nil && state.createdAt != nil ) {
10411053 state.updatedAt = state.createdAt ;
10421054 }
@@ -1053,6 +1065,7 @@ - (void)mergeFromRESTDictionary:(NSDictionary *)object withDecoder:(PFDecoder *)
10531065 }
10541066 }
10551067 [self rebuildEstimatedData ];
1068+ return YES ;
10561069 }
10571070}
10581071
0 commit comments