joa*_*oan 2 multithreading objective-c ios
我看到以下行:
@property (nonatomic, strong) dispatch_queue_t filterMainQueue;
Run Code Online (Sandbox Code Playgroud)
为什么声明dispatch_queue_t的实例,它不是一个对象,强大?
这是一个很好的做法.我想要注意的是,自 OS X Mountain Lion和iOS 6.0 以来,iOS/OS X运行时中的所有GCD和XPC对象现在都被视为Objective-C对象,ARC
现在它们不是原语,所以它们将以与内存管理相同的方式进行内存管理.通常的Objective-C对象.这就是为什么从现在起你应该将它们声明为strong
.
您可以自己检查object.h
:
#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS(name, dispatch_object)
Run Code Online (Sandbox Code Playgroud)
这一事实也说明在文档:
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
:
* By default, dispatch objects are declared as Objective-C types when building
* with an Objective-C compiler. This allows them to participate in ARC, in RR
* management by the Blocks runtime and in leaks checking by the static
* analyzer, and enables them to be added to Cocoa collections.
* See <os/object.h> for details.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
832 次 |
最近记录: |