NSOperationQueue,NSOperation

2019-08-01 05:00发布

I m new to iphone. where i get examples for NSOperationQueue, NSOperation?
What is the advantage of NSOperationQueue, NSOperation over thread?

Thanks

3条回答
放荡不羁爱自由
2楼-- · 2019-08-01 05:42
SAY GOODBYE
3楼-- · 2019-08-01 05:52

NSOperationQueue:

An NSOperationQueue object is a queue that handles objects of the NSOperation class type. The NSOperationQueue handles and manages the execution of all the NSOperation objects (the tasks) that have been added to it. The execution takes place with the main thread of the application. When an NSOperation object is added to the queue it is executed immediately and it does not leave the queue until it is finished. A task can be cancelled, but it is not removed from the queue until it is finished.

NSOperation:

NSOperation is designed to handle more-or-less batch operations. An NSOperation object, simply phrased,represents a single task, including both the data and the code related to the task. The NSOperation class is an abstract one so it cannot be used directly in the program. Instead, there are two provided subclasses, the NSInvocationOperation class and the NSBlockOperation class.

OfCourse for more details Apple iOS Developer Library is the best option and the link below would also help to know more about it and NSOperationQueue, NSOperation VS thread.

NSThread vs. NSOperationQueue vs. ??? on the iPhone

http://www.raywenderlich.com/19788/how-to-use-nsoperations-and-nsoperationqueues

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-08-01 05:56

Higher level of abstraction: That is, easier to program than NSThreads and a little bit less control than NSThread.

查看更多
登录 后发表回答