【发布时间】:2012-11-22 01:36:23
【问题描述】:
我声明了一个引用 GCD 队列的属性:
@property (assign) dispatch_queue_t backgroundQueue;
在一个类的 init 方法中,我创建了一个串行队列:
backgroundQueue = dispatch_queue_create("com.company.app", DISPATCH_QUEUE_SERIAL);
ARC 报错:“将保留对象分配给 unsafe_unretained 变量;分配后对象将被释放”
我必须使用 __bridge_transfer 吗?
在 -dealloc 中我正在释放队列:
dispatch_release(backgroundQueue);
ARC 再次抱怨:“ARC 禁止发送明确的 'release' 消息”
我觉得这很令人困惑,因为这是一个 C 函数调用,并且认为队列是 C 对象,我必须自己负责内存管理! ARC 从什么时候开始为我处理 C 对象?
【问题讨论】:
标签: ios memory-management automatic-ref-counting grand-central-dispatch