GroupOperation Finished not called when adding operation
I notice that in a GroupOperation, if you generate a new operation in the method
operationDidFinish(_ operation: Foundation.Operation, withErrors errors: [NSError])
using addOperation
the finished(_ errors: [NSError]) is not called
example: GroupOperation that contains OperationA & OperationB
when OperationB finish, you want to generate OperationC on a particular condition
OperationC will be execute successfully and the block observer will be called correctly, however the GroupOperation won't called it's finish method
Is that a bug ?
thanks
Just found something, I was generating 2 operations using the AddOperation, if I only generate one, the finished will be called
as stated in the example: when OperationB finish I am generating 2 independent operations (C & D) using the AddOperation, by doing this it looks like the BlockOberser finish completion handler is not called and the finish method also
Workaround: Generate Operation C and in the same method
operationDidFinish(_ operation: Foundation.Operation, withErrors errors: [NSError])
wait for it to finish and generate OperationD and it will works
ALEX
@agiguere Are you saying before you would do something like this (and it wasn't working)?
func operationDidFinish(_ operation: Foundation.Operation, withErrors errors: [NSError]) {
if operation === operationB {
addOperation(OperationC())
addOperation(OperationD())
}
}
and now you're doing this (and it is working)?
func operationDidFinish(_ operation: Foundation.Operation, withErrors errors: [NSError]) {
if operation === operationB {
addOperation(OperationC())
} else if operation === operationC {
addOperation(OperationD())
}
}
Asking for clarification because I'm running into similar issues.