What is the difference between NSInvocationOperation and NSBlockOperation

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

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

I already

3条回答
  •  抹茶落季
    2021-02-04 06:42

    NSOperation is the base class. All operations extend NSOperation. But it is an abstract class, meaning that you need to subclass it and implement the code that performs the actual operation.

    For simple cases, this (making your own subclass) is not necessary, however.

    If you just want to pass a message to an object, you can use NSInvocationOperation. This is an implementation of NSOperation that can be parameterized with a selector and a target object.

    If you just want to call one more blocks, you can use NSBlockOperation. This is an implementation of NSOperation that can be parameterized with a block to call.

提交回复
热议问题