Search code examples
iosnsoperationnsoperationqueuensexceptionnsblockoperation

Understanding NSBlockOperation


I'm getting into NSBlockOperation and I have some questions. Notably, the documentation for addExecutionBlock says:

Discussion

The specified block should not make any assumptions about its execution environment.

Calling this method while the receiver is executing or has already finished causes an NSInvalidArgumentException exception to be thrown.

What kind of situation will throw NSInvalidArgumentException? What really doesn "while receiver is executing" mean? What can cause this?


Solution

  • You can't use addExecutionBlock: to add an execution block while the operation is running or has already completed. That's all it means.