Question

I am using UniRest for objective c, and I'm making a request to my server.

#import <Foundation/Foundation.h>
#import "Essay.h"
#import "grammarCheck.h"

int main(int argc, const char * argv[])
{
    NSDictionary* headers = @{@"accept": @"application/json"};
    NSDictionary* parameters = @{@"parameter": @"value", @"foo": @"bar"};

    [[UNIRest get:^(UNISimpleRequest* request) {
        [request setUrl:@"http://thomaswd.net:8081/?language=en&text=my+text"];
        [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];

        NSLog(@"%@",rawBody);
    }];

    return 0;
}

However, NSLog(@"%@",rawBody); is not logging the results. Any idea why?

Was it helpful?

Solution

add this line before return 0;

[[NSRunloop currentRunLoop] run];

it start the runloop so to process async request

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top