Reputation: 1033
Here I have a bunch of dispatch_queue_t, and I want to organize them with a NSArray. But as far as I know, there's no such API to do so. So how can i achieve that?
Upvotes: 0
Views: 354
Reputation: 14009
NSArray
is not mutable. You must use NSMutableArray
, that is subclass of NSArray
, to add objects.
And, from iOS 6.0 SDK and the Mac OS X 10.8 SDK, Dispatch Queue is declared as Objective-C types. Thus you can use Dispatch Queue object as Objective-C object.
@import Foundation;
int main()
{
NSMutableArray *array = [[NSMutableArray alloc] init];
dispatch_queue_t q = dispatch_get_global_queue(0, 0);
NSLog(@" q=%@", q);
[array addObject:q];
NSLog(@"array[0]=%@", array[0]);
return 0;
}
Result:
q=<OS_dispatch_queue_root: com.apple.root.default-qos[0x7fff79749b40]>
array[0]=<OS_dispatch_queue_root: com.apple.root.default-qos[0x7fff79749b40]>
Upvotes: 2