Difference between NSOperation and NSInvocationOperation?

1) what happens when we add NSOperation or NSInvocationOperation to NSoperationQueue ?

2) What is the difference between NSOperation and NSInvocationOperation ?

3) which one is better?

+4
source share
2 answers

1. The difference between NSoperation and NSInvocationOperation

An NSoperation object is a one-shot object, that is, it performs its task once and cannot be used to restart it.

The NSInvocationOperation class is a specific subclass of NSOperation that controls the execution of a single encapsulated task, indicated as a call. You can use this class to start an operation consisting in invoking a selector on a specified object. This class implements a non-competitive operation.

2. What happens when we add NSOperation or NSInvocationOperation to NSoperationQueue

You typically perform operations by adding them to the operation queue (an instance of the NSOperationQueue class). The operational queue performs its operations either directly, running them on secondary threads, or indirectly using the libdispatch library (also known as Grand Central Dispatch)

3. Which one is the best

I think the word Best may vary depending on your situation :)

+11
source

Cocoa My friend has a good tutorial on using NSOperation and NSOperationQueue. The tutorial uses NSOperation to load multiple web pages simultaneously in separate streams.

Also, see this article from Mac Research.There is another tutorial.

Also check out this NSOperation question on iPhone

0
source

Source: https://habr.com/ru/post/1439971/


All Articles