Problem about using NSOperationQueue and NSOperation in iphone OS
Im using NSOperation to do a task: download some files with NSURLConnection and then m开发者_如何学Cerge files that spend much cpu and memory
I need to excute the task in new/background thread So I add some these tasks to NSOperationQueue and set maxConcurrentOperationCount = 2 But the result is when merging files it will block the main thread(UI not respond for a while) ,it seems not excuting in new/background thread how to make it go as I expected ?What type of operations are you putting in the NSOperationQueue? Apple's documentation for the NSOperationQueue includes this note:
Note: In iOS, operation queues do not use Grand Central Dispatch to execute operations. They create separate threads for non-concurrent operations and launch concurrent operations from the current thread. For a discussion of the difference between concurrent and non-concurrent operations and how they are executed, see NSOperation Class Reference.
Since you using NSOperationqueue,therefore you are having only two files at one time and you can merge only them because all the other threads or files are not present there.
So for merging them together you will have to keep them together at one time.
精彩评论