Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GroupOperation Finished not called when adding operation #87

Open
agiguere opened this issue Feb 6, 2017 · 2 comments
Open

GroupOperation Finished not called when adding operation #87

agiguere opened this issue Feb 6, 2017 · 2 comments

Comments

@agiguere
Copy link

agiguere commented Feb 6, 2017

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

@agiguere
Copy link
Author

agiguere commented Feb 6, 2017

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

@jjatie
Copy link

jjatie commented Nov 27, 2018

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants