diff --git a/Code/Network/RKManagedObjectRequestOperation.m b/Code/Network/RKManagedObjectRequestOperation.m index 3d9cb1b0cc..07cf12d74e 100644 --- a/Code/Network/RKManagedObjectRequestOperation.m +++ b/Code/Network/RKManagedObjectRequestOperation.m @@ -315,6 +315,17 @@ - (id)initWithHTTPRequestOperation:(RKHTTPRequestOperation *)requestOperation re return self; } +/** + NOTE: This dealloc implementation attempts to avoid crashes coming from Core Data due to the ordering of deallocations under ARC. If the MOC is deallocated before its managed objects, it can trigger a crash. We dispose of the mapping result and reset the private context to avoid this situation. The crash manifests itself in `cxx_destruct` + [sbw - 2/25/2013] + */ +- (void)dealloc +{ + _mappingResult = nil; + _responseMapperOperation = nil; + _privateContext = nil; +} + - (void)setTargetObject:(id)targetObject { [super setTargetObject:targetObject]; diff --git a/Code/Network/RKObjectRequestOperation.h b/Code/Network/RKObjectRequestOperation.h index e43c33c12e..227017307e 100644 --- a/Code/Network/RKObjectRequestOperation.h +++ b/Code/Network/RKObjectRequestOperation.h @@ -62,7 +62,10 @@ @see `RKMIMETypeSerialization` @see `RKManagedObjectRequestOperation` */ -@interface RKObjectRequestOperation : NSOperation +@interface RKObjectRequestOperation : NSOperation { + @protected + RKMappingResult *_mappingResult; +} ///----------------------------------------------- /// @name Initializing an Object Request Operation