Cocoa 内存管理用于更深入的后台工作
目前我在课堂上做了一些工作:Cocoa 内存管理用于更深入的后台工作,cocoa,Cocoa,目前我在课堂上做了一些工作: [userController startRegistrationForAllObjectsInFutureArrayForTableView:nil]; 这是一个函数: -(void) startRegistrationForAllObjectsInFutureArrayForTableView:(id)tableView; { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORIT
[userController startRegistrationForAllObjectsInFutureArrayForTableView:nil];
这是一个函数:
-(void) startRegistrationForAllObjectsInFutureArrayForTableView:(id)tableView;
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^(void) {
... some job here
});
所以,这项工作将成为背景。但我仍然需要释放类后,所有的工作将完成。
那么解决这个问题的方法是什么呢?
目前我的做法如下:
[userController retain];
[userController startRegistrationForAllObjectsInFutureArrayForTableView:nil];
}
[userController release];
[pool drain], pool = nil;
但我不确定它是否正常工作,以及当自动释放池不存在时发生了什么。
Tnx