Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using blocks in Restkit (like ASIHttpRequest Blocks)

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 delegate call back a seperate function

Here is the example 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 be able to use Restkit with blocks as well.

I have seen the wrapper here Restkit Block Wrapper, but would like to check if that wrapper would work well in production, and if anyone have used it extensively before

like image 755
meow Avatar asked Jun 11 '11 00:06

meow


1 Answers

I have not used the RestKit Block wrapper yet, but I will be shortly. I'm actually removing ASIHTTPRequest from my App and replacing with RestKit. Not because it's bad, ASIHTTP* is quite stable - but it isn't evolving. While many other libraries, like RestKit, wrap NSURLConnection and so reap the benefits of Apples continuing enhancements to it, ASIHTTP* uses CFNetwork. Apple isn't investing a lot of effort in improving preexisting Core Foundation classes (like CFNetwork). Also, since ASIHTTP* depends on CF, it's going to be a royal pain to migrate to ARC when it's available; I wan't the benefits of ARC as soon as possible.

like image 154
RyanR Avatar answered Nov 15 '22 22:11

RyanR