开发者

NSOperationQueue,NSOperation

开发者 https://www.devze.com 2023-02-15 05:55 出处:网络
I m new to iphone. where i get examples for NSOperationQueue, NSOperation? What is the advantage of NSOperationQueue, NSOperation over thread开发者_开发技巧?

I m new to iphone. where i get examples for NSOperationQueue, NSOperation?

What is the advantage of NSOperationQueue, NSOperation over thread开发者_开发技巧?

Thanks


Read the docs. They are really good at explaining and giving examples

http://developer.apple.com/library/ios/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationObjects/OperationObjects.html%23//apple_ref/doc/uid/TP40008091-CH101-SW1

NSOperation is easier to manage than NSThread.


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消