mam*_*mcx 5 delegates ios objective-c-blocks xcode4 ios5
我正在为我的新项目应用程序实现dropbox api.api基于代表和回调,成对(成功+失败),如:
- (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata;
- (void)restClient:(DBRestClient*)client loadMetadataFailedWithError:(NSError*)error;
- (void)restClient:(DBRestClient*)client loadedAccountInfo:(DBAccountInfo*)info;
- (void)restClient:(DBRestClient*)client loadAccountInfoFailedWithError:(NSError*)error;
Run Code Online (Sandbox Code Playgroud)
我想知道是否存在将其转换为obj-c异步块的方法,所以我可以这样做:
+ (void)loadMetadata:(DBRestClient *)client queue:(NSOperationQueue *)queue completionHandler:(void (^)(DBMetadata*, NSError*))handler
Run Code Online (Sandbox Code Playgroud)
存在一种可用于此的模式?或者必须从一开始就用块构建库?
现在有一个名为"DropBlocks"的开源库,它提供了所有Dropbox iOS SDK功能的基于块的版本.
https://github.com/natep/DropBlocks
完全披露:我是这个图书馆的作者.我在对这个问题中描述的委托范式感到沮丧之后写了它.请随时查看源代码,了解我是如何实现它的.
| 归档时间: |
|
| 查看次数: |
899 次 |
| 最近记录: |