Reputation: 135
actually what I wanna do is just sending a JSONString with a POST-Request to a server and achieve the "OK" in the response's header.
What framework would you suggest for this purpose? I already looked at restkit but it's way too huge for my purpose imo. I would prefer a slim framework/solution.
Thanks in advance
Upvotes: 0
Views: 442
Reputation: 1788
doesn't sound like you need a Framework here as @dasblinkenlight has already commented you should probably just use NSURLRequest.
-(BOOL)sendRequestToURL:(NSString*)stringURL withJSON:(NSString*)JSONAsAString{
NSError *jsonERROR =nil;
__block BOOL success = NO;
NSOperationQueue* queue = [[NSOperationQueue alloc]init];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:stringURL]];
request.HTTPMethod = @"POST";
request.HTTPBody = [NSJSONSerialization dataWithJSONObject:JSONAsAString options:0 error:&jsonERROR];
if (!jsonERROR){
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError * error) {
NSHTTPURLResponse *httpResonse = (NSHTTPURLResponse*)response;
if (httpResonse.statusCode == 200 ) {
success = YES;
}
}];
} else {
NSLog(@"jsonERROR: %@", jsonERROR.description);
}
return NO;
}
Upvotes: 1