本文介绍了在Restkit中使用块(如ASIHttpRequest Blocks)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在ASIHttpRequest中广泛使用块支持,我发现它是一种非常优雅的编码异步请求的方式,远远超过让委托回调单独的函数

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];

我想开始使用Restkit,但我需要能够将Restkit与块一起使用。

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

推荐答案

我还没有使用过RestKit Block包装器,但我很快就会用到。我实际上正在从我的应用程序中删除ASIHTTPRequest并替换为RestKit。不是因为它很糟糕,ASIHTTP *非常稳定 - 但它并没有发展。虽然许多其他库,如RestKit,包装NSURLConnection,因此收获苹果继续增强它的好处,ASIHTTP *使用CFNetwork。 Apple并没有投入大量精力来改进已有的Core Foundation类(如CFNetwork)。此外,由于ASIHTTP *依赖于CF,因此当它可用时,迁移到ARC将会是皇家的痛苦;我不想尽快获得ARC的好处。

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.

这篇关于在Restkit中使用块(如ASIHttpRequest Blocks)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 10:13