I have added a more concise answer now, left this for the time being as it was part of a discussion...
Ok, I was quite happy with my use of the isConcurrent
method until today !
I read the sentence:
In OS X v10.6 and later, operation queues ignore the value returned by
this method and always start operations on a separate thread.
As a warning relating to QA1712, pointing out that for concurrent operations the start
method can now be called on a different thread to the one that queued the operation, which is a change in 10.6 and iOS 4.
I didn't read this as indicating that the isConcurrent
method is ignored completely by the queue and has no purpose at all, just that it no longer effects the thread on which start
is called. I may have misunderstood this.
I also misunderstood the original question as a more general one about concurrent operations and the isConcurrent
flag, and the accepted answer as effectively saying
The isConcurrent
flag can be ignored since 10.6 and iOS 4
I'm not sure this is correct.
If I understand the original question now, to paraphrase:
Given a correctly built concurrent NSOperation
does the isConcurrent
flag itself actually alter the execution of the operation at all?
I guess it's hard to say for all possible setups, but we can say that:
It's not deprecated. It's normal for Apple to deprecate methods
that are no longer useful.
The documentation consistently refers to the method being a required
override.
Perhaps isConcurrent
is effectively deprecated but as it's only a single BOOL
flag perhaps it's not worth the effort to deprecate it in the docs. Or perhaps it does nothing now but Apple have kept it for possible future use and expect you to override it as described.
I created a quick test project with an NSOperation
that overrode isConcurrent
and main
only, isConcurrent
was not called at any stage. It was a very simple test though. I assume you may have tested it also? I assumed perhaps if the NSOperationQueue
didn't call it NSOperation's
default implementation of start
might.
So where does that leave us? Obviously it's no trouble to implement it and return YES
to satisfy the documented requirements. However from my perspective I think it's too much of a leap to go from the caveat regarding 10.6 and iOS 4.0 to say that it can be safely ignored now.
My Original Answer...
isConcurrent
is not a legacy method and is not ignored by NSOperationQueue
. The documentation as quoted in the other answers is a little unclear and easily misunderstood.
isConcurrent = YES
means the operation provides its own means of concurrency. Or to put it another way, the operation "isAlreadyConcurrent"
and doesn't need the NSOperationQueue
to provide and manage the concurrency. As NSOperationQueue
is no longer providing the concurrency you need to tell it when the operation isFinished
or if it isCancelled
(etc) hence the need to override these methods.
A common example is an NSOperation
that manages an NSURLConnection
. NSURLConnection
has it's own mechanism for running in the background, so doesn't need to be made concurrent by NSOperationQueue
.
An obvious question is then: "Why put an already concurrent operation into an NSOperationQueue
?" It's so the operation can benefit from the other features of the NSOperationQueue
like dependencies etc.
The misleading part of the documentation is referring only to what thread the start
method of an NSOperation
is called on. The change caused a problem discussed in QA1712.