我正在阅读有关 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