Last active
August 29, 2015 14:03
-
-
Save ttran4040/a7b5f08319e0b271ffdc to your computer and use it in GitHub Desktop.
Unirest Asynchronous Requests
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
NSDictionary* headers = @{@"accept": @"application/json"}; | |
NSDictionary* parameters = @{@"parameter": @"value", @"foo": @"bar"}; | |
[[UNIRest post:^(UNISimpleRequest* request) { | |
[request setUrl:@"http://httpbin.org/post"]; | |
[request setHeaders:headers]; | |
[request setParameters:parameters]; | |
}] asJsonAsync:^(UNIHTTPJsonResponse* response, NSError *error) { | |
// This is the asyncronous callback block | |
NSInteger* code = [response code]; | |
NSDictionary* responseHeaders = [response headers]; | |
UNIJsonNode* body = [response body]; | |
NSData* rawBody = [response rawBody]; | |
NSDictionary *json_response = response.body.JSONObject; | |
NSLog(@"JSON State Result:%@", json_response[@"status_code"]); | |
}]; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment