【发布时间】:2012-07-02 16:06:16
【问题描述】:
我正在阅读有关 Grand Central Dispatch 的文档,其中有两个函数称为 Block_copy 和 Block_release。
根据文档,这些方法在调用dispatch_async 来处理块的内存管理时被使用。我想在我的代码中做同样的事情吗?
我下面的代码有问题吗?
typedef void (^MyCompletionHandler)(NSError *error)
@interface ServiceClient
- (void)fetchWithCompletionHandler:(MyCompletionHandler)completionHandler;
@property (nonatomic, assign) MyCompletionHandler completionHandler;
@end
@implementation ServiceClient
@synthesize completionHandler = _completionHandler;
- (void)fetchWithCompletionHandler:(MyCompletionHandler)completionHandler
{
self.completionHandler = completionHandler;
[self performSelectorInBackground:@selector(fetchInBackground)];
}
@end
【问题讨论】:
标签: objective-c memory-management objective-c-blocks grand-central-dispatch