Is it safe to list through [NSOperationQueue operations]?

Is it possible to list by quick listing through [NSOperationQueue operations]? For instance:

for (NSOperation *op in [operationQueue operations]) {
    // Do something with op
}

Since operations are asynchronous and performed in another thread, it operationscan change at any time (including during the execution of the main thread). Does fast enumeration protect against this, or should I copy(and autorelease) use an array of operations?

+5
source share
1 answer

This is only unsafe if the queue mutates the array while you enumerate it.

However:

Returns a new array containing the current operations in the queue.

"" , , .

+11

All Articles