I saw the following line:
@property (nonatomic, strong) dispatch_queue_t filterMainQueue;
Why is declared an instance of dispatch_queue_t, which is not an object, as strong?
I saw the following line:
@property (nonatomic, strong) dispatch_queue_t filterMainQueue;
Why is declared an instance of dispatch_queue_t, which is not an object, as strong?
This is totally a good practice. I want to notice that since OS X Mountain Lion and iOS 6.0 all GCD and XPC objects in iOS/ OS X runtimes are now treated as Objective-C objects by ARC
and they are not primitives now so they will be memory-managed the same way as usual Objective-C objects. That's why from now you should declare them as strong
.
You can check this yourself in object.h
:
#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS(name, dispatch_object)
This fact is also stated in the docs:
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
And also from the comments in 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.