Created
November 16, 2011 00:00
-
-
Save blakewatters/1368819 to your computer and use it in GitHub Desktop.
sendData:toResourcePath:usingBlock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Encode some arbitrary data and send it to the remote server. Object mapping will be performed on the results | |
- (RKObjectLoader *)sendData:(id)data toResourcePath:(NSString *)resourcePath usingBlock:(void (^)(RKObjectLoader *objectLoader))block { | |
RKObjectLoader* loader = [self objectLoaderWithResourcePath:resourcePath delegate:nil]; | |
id<RKParser> parser = [[RKParserRegistry sharedRegistry] parserForMIMEType:self.serializationMIMEType]; | |
NSString* string = [parser stringFromObject:serializedObject error:error]; | |
NSData* data = [string dataUsingEncoding:NSUTF8StringEncoding]; | |
loader.params = [RKRequestSerialization serializationWithData:data MIMEType:self.serializationMIMEType]; | |
loader.method = RKRequestMethodPOST; | |
// Yield to the block for setup | |
block(loader); | |
[loader send]; | |
return loader; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment