为什么苹果说 Operation is abstract class?

Why apple says Operation is abstract class?

如果swift没有抽象class,那苹果为什么说Operation是抽象class?

根据基础文档,操作是:

An abstract class that represents the code and data associated with a single task.

也来自同一文档:

Because the NSOperation class is an abstract class, you do not use it directly but instead subclass or use one of the system-defined subclasses (NSInvocationOperation or NSBlockOperation) to perform the actual task. Despite being abstract, the base implementation of NSOperation does include significant logic to coordinate the safe execution of your task. The presence of this built-in logic allows you to focus on the actual implementation of your task, rather than on the glue code needed to ensure it works correctly with other system objects.

NSOperation 有其具体的对应物,例如 NSBlockOperation

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.

尽管 Objective-C 没有像其他编程语言那样正式提供抽象 类(例如:Java),但实现它们是可能的,Apple 在其许多元素中都做到了SDK。