Files
RestKit/Code/Network/RKRequestSerialization.m
Blake Watters f3c0995d5e Implementation of Object Mapping 2.0 design:
* Removed RestKit from inheritance hierarchy
  * Mappings are implemented as concrete classes
  * Mapper is much more flexible & powerful
  * Much more robust error handling
  * Serialization is reimplemented as an object mapping operation
  * Added ability to serialize to JSON natively
  * Reworked Core Data integration
  * Simplified the codebase substantially
2011-06-11 19:26:56 -04:00

53 lines
1.1 KiB
Objective-C

//
// RKRequestSerialization.m
// RestKit
//
// Created by Blake Watters on 5/18/11.
// Copyright 2011 Two Toasters. All rights reserved.
//
#import "RKRequestSerialization.h"
@implementation RKRequestSerialization
@synthesize data = _data;
@synthesize MIMEType = _MIMEType;
- (id)initWithData:(NSData*)data MIMEType:(NSString*)MIMEType {
NSAssert(data, @"Cannot create a request serialization without Data");
NSAssert(MIMEType, @"Cannot create a request serialization without a MIME Type");
self = [super init];
if (self) {
_data = [data retain];
_MIMEType = [MIMEType retain];
}
return self;
}
+ (id)serializationWithData:(NSData*)data MIMEType:(NSString*)MIMEType {
return [[[RKRequestSerialization alloc] initWithData:data MIMEType:MIMEType] autorelease];
}
- (void)dealloc {
[_data release];
[_MIMEType release];
[super dealloc];
}
- (NSString*)HTTPHeaderValueForContentType {
return self.MIMEType;
}
- (NSData*)HTTPBody {
return self.data;
}
- (NSUInteger)HTTPHeaderValueForContentLength {
return [self.data length];
}
@end