I m new to iphone. where i get examples for NSOperationQueue
, NSOperation
?
What is the advantage of NSOperationQueue
, NSOperation
over thread?
Thanks
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.
NSOperationQueue
:An
NSOperationQueue
object is a queue that handles objects of theNSOperation
class type. TheNSOperationQueue
handles and manages the execution of all theNSOperation
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. AnNSOperation
object, simply phrased,represents a single task, including both the data and the code related to the task. TheNSOperation
class is an abstract one so it cannot be used directly in the program. Instead, there are two provided subclasses, theNSInvocationOperation
class and theNSBlockOperation
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
Higher level of abstraction: That is, easier to program than
NSThreads
and a little bit less control thanNSThread
.