I'm trying to add a dispatch_queue_t
to a NSMutableArray
like so:
NSMutableArray* queuesWaitingForTargetQueue = (__bridge NSMutableArray*)dispatch_queue_get_specific(targetQueue, WAITING_QUEUE_LIST_KEY);
NSLog(@" dispatch_get_current_queue() = %#x", (unsigned int)dispatch_get_current_queue());
NSLog(@" dispatch_get_main_queue() = %#x", (unsigned int)dispatch_get_main_queue());
NSLog(@" currQueueId = %#x", (unsigned int)currQueueId);
NSLog(@" queuesWaitingForTargetQueue = %#x (%@)", (unsigned int)queuesWaitingForTargetQueue, NSStringFromClass([queuesWaitingForTargetQueue class]));
[queuesWaitingForTargetQueue addObject:(__bridge id)currQueueId];
The last line sometimes fails with EXC_BAD_ACCESS:
Thread 1: EXC_BAD_ACCESS (code=1, address=0xc08314eb)
While the output was:
dispatch_get_current_queue() = 0x2879640
dispatch_get_main_queue() = 0x2879640
currQueueId = 0x2879640
queuesWaitingForTargetQueue = 0x8672ae0 (__NSArrayM)
What could be wrong here?