dispatch_queue_t的定义很强

时间:2014-06-26 11:37:30

标签: ios objective-c multithreading

我看到以下一行:

@property (nonatomic, strong) dispatch_queue_t filterMainQueue;

为什么声明dispatch_queue_t的实例(不是对象)强大?

1 个答案:

答案 0 :(得分:7)

这是一个很好的做法。我想注意因为 OS X Mountain Lion和iOS 6.0,iOS / OS X运行时中的所有GCD和XPC对象现在被{{1}视为Objective-C对象它们现在不是原语,因此它们将像通常的Objective-C对象一样进行内存管理。这就是为什么从现在起你应该将它们声明为ARC

您可以在strong

中自行查看
object.h

docs中的{b>陈述:#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS(name, dispatch_object)

还有 iOS 6 and later—Dispatch objects (including queues) are Objective-C objects, and are retained and released automatically. OS X 10.8 and later—Dispatch objects (including queues) are Objective-C objects, and are retained and released automatically. Earlier versions—Dispatch objects are custom objects. You must handle the reference counting manually中的评论:

object.h