What is the difference between NSInvocationOperation and NSBlockOperation

前端 未结 3 660
臣服心动
臣服心动 2021-02-04 06:11

There are three operation classes in Foundation Framework(NSOperation, NSInvocationOperation and NSBlockOperation).

I already

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-04 06:48

    As par Apple doc NSInvocationOperation and NSBlockOperation Both are subclass of NSOperation

    NSInvocationOperation Class

    The NSInvocationOperation class is a concrete subclass of NSOperation that manages the execution of a single encapsulated task specified as an invocation. You can use this class to initiate an operation that consists of invoking a selector on a specified object. This class implements a non-concurrent operation


    NSBlockOperation Class

    The NSBlockOperation class is a concrete subclass of NSOperation that manages the concurrent execution of one or more blocks. You can use this object to execute several blocks at once without having to create separate operation objects for each. When executing more than one block, the operation itself is considered finished only when all blocks have finished executing.

    Blocks added to a block operation are dispatched with default priority to an appropriate work queue. The blocks themselves should not make any assumptions about the configuration of their execution environment.

提交回复
热议问题