Using blocks in Restkit (like ASIHttpRequest Blocks)

前端 未结 4 722
梦毁少年i
梦毁少年i 2021-02-09 05:19

i have been using the block support extensively in ASIHttpRequest, and i have found it to be an extremely elegant way of coding async requests, much more so than having the dele

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-09 05:49

    For a quick code sample to use RestKit with blocks, I derived this snippet from http://kalapun.com/blog/2012/05/17/how-i-restkit/

    [[RKClient sharedClient] get:@"/fooBar" usingBlock:^(RKRequest *request) {
    
        request.onDidLoadResponse = ^(RKResponse *response) {
    
            NSLog(@"Retrieved XML: %@", [response bodyAsString]); 
        };
    }];
    

提交回复
热议问题