Using blocks in Restkit (e.g. ASIHttpRequest Blocks)

I made extensive use of block support in ASIHttpRequest, and I found it to be an extremely elegant way of encoding asynchronous requests, and moreover, the delegate called back a separate function

Here is sample code for quick reference.

__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setCompletionBlock:^{ NSString *responseString = [request responseString]; }]; [request startAsynchronous]; 

I would like to start using Restkit, but I need to also use Restkit with blocks.

I saw the Restkit Block Wrapper wrapper here, but would like to check if this wrapper will work well in production, and if anyone has used it extensively before

+7
source share
4 answers

I haven't used a RestKit block wrapper yet, but I will soon. I actually remove ASIHTTPRequest from my application and replace RestKit. Not because it's bad, ASIHTTP * is pretty stable - but it is not developing. While many other libraries, such as RestKit, port NSURLConnection and thus take advantage of Apple enhancements, ASIHTTP * uses CFNetwork. Apple does not put much effort into improving existing Core core classes (such as CFNetwork). Also, since ASIHTTP * is CF dependent, it will be a royal pain to switch to ARC when it is available; I will not take advantage of ARC as soon as possible.

+8
source

Blocks support for all basic delegate tasks in RKRequest, and RKObjectLoader will be included in 0.9.4

+7
source

Blake released verson 0.9.3 yesterday , which uses blocks for Map Mapper (other methods were ready for blocks). You should take a look at the new features.

+3
source

For a quick example of code using RestKit with blocks, I got 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]); }; }]; 
+1
source

All Articles