RestKit/RestKit — pull request #1654 by jleach (2013-10-30 16:20:17+00:00)
Title: Add NULL pointer check on NSError and remove unused code.

Hi,

These two comments are in reference to Issue #1652.

Not checking for a NULL value in `*error` was causing an EXC_BAD_ACCESS exception when the block in the following selector returned NO:

`+ (instancetype)expectationWithSourceKeyPath:(NSString *)sourceKeyPath destinationKeyPath:(NSString *)destinationKeyPath evaluationBlock:(RKMappingTestExpectationEvaluationBlock)evaluationBlock`

` if (error) *error = [self errorForExpectation:expectation
withCode:RKMappingTestEvaluationBlockError
userInfo:userInfo
description:description
reason:reason];`

The second commit was to remove the assignment to `*error` on line 239; its immediately overwritten on line 254 so it seems pointless:

`NSMutableDictionary *mutableUserInfo = [userInfo mutableCopy];
[mutableUserInfo setValue:blockError forKey:NSUnderlyingErrorKey];
NSString *reason = [NSString stringWithFormat:@"expected to %@ with value %@ '%@', but it did not",
expectation, [event.value class], event.value];
*error = [self errorForExpectation:expectation
withCode:RKMappingTestEvaluationBlockError
userInfo:mutableUserInfo
description:[blockError localizedDescription]
reason:reason];

*error = blockError;`