diff --git a/Code/Network/RKObjectRequestOperation.m b/Code/Network/RKObjectRequestOperation.m index 46b1b5c8..daf74145 100644 --- a/Code/Network/RKObjectRequestOperation.m +++ b/Code/Network/RKObjectRequestOperation.m @@ -67,6 +67,31 @@ static NSIndexSet *RKObjectRequestOperationAcceptableMIMETypes() return statusCodes; } +static NSString *RKStringForStateOfObjectRequestOperation(RKObjectRequestOperation *operation) +{ + if ([operation isExecuting]) { + return @"Executing"; + } else if ([operation isFinished]) { + if (operation.error) { + return @"Failed"; + } else { + return @"Successful"; + } + } else { + return @"Ready"; + } +} + +static NSString *RKStringDescribingURLResponseWithData(NSURLResponse *response, NSData *data) +{ + if ([response isKindOfClass:[NSHTTPURLResponse class]]) { + NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)response; + return [NSString stringWithFormat:@"<%@: %p statusCode=%ld MIMEType=%@ length=%ld>", [response class], response, (long) [HTTPResponse statusCode], [HTTPResponse MIMEType], (long) [data length]]; + } else { + return [response description]; + } +} + @interface RKObjectRequestOperation () @property (nonatomic, strong, readwrite) RKHTTPRequestOperation *HTTPRequestOperation; @property (nonatomic, strong, readwrite) NSArray *responseDescriptors; @@ -257,4 +282,11 @@ static NSIndexSet *RKObjectRequestOperationAcceptableMIMETypes() [[NSNotificationCenter defaultCenter] postNotificationName:RKObjectRequestOperationDidFinishNotification object:self]; } +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, state: %@, isCancelled=%@, request: %@, response: %@>", + NSStringFromClass([self class]), self, RKStringForStateOfObjectRequestOperation(self), [self isCancelled] ? @"YES" : @"NO", + self.HTTPRequestOperation.request, RKStringDescribingURLResponseWithData(self.HTTPRequestOperation.response, self.HTTPRequestOperation.responseData)]; +} + + @end diff --git a/Code/ObjectMapping/RKPropertyMapping.m b/Code/ObjectMapping/RKPropertyMapping.m index 13856deb..09f35071 100644 --- a/Code/ObjectMapping/RKPropertyMapping.m +++ b/Code/ObjectMapping/RKPropertyMapping.m @@ -46,7 +46,7 @@ - (NSString *)description { - return [NSString stringWithFormat:@"<%@:%p %@ => %@>", self.class, self, self.sourceKeyPath, self.destinationKeyPath]; + return [NSString stringWithFormat:@"<%@: %p %@ => %@>", self.class, self, self.sourceKeyPath, self.destinationKeyPath]; } @end