fix: double calling of delegate
I encountered a bug: I created a custom class that inherited from CropViewController and made an extension for this class, which implemented the CropViewControllerDelegate. When I initialized the delegate in the class constructor with a reference to the class itself, the delegate methods started executing twice. This pull request is a fix.
Hey @Ans3301! Thanks for the PR!
Hmm, the idea was to in fact allow the delegate and the blocks to execute at the same time in case the user wanted it, so I feel like changing the logic to choose between the two might break expectations for a lot of people. Are you sure you can't fix this some other way?
Hi @TimOliver! Thanks for your response! I understand that this is a breaking change, but I don't quite understand in what use case two calls might be needed. Could you please provide an example of such usage?
If I have to pick an example, my old favorite is 'logging'. :)
The main concern I have is this might break existing implementations. This wasn't a great pattern for me to choose originally. Next time I'll probably only stick to delegates. 😅
Maybe a good way to solve this is add a new enum, like TOCropViewControllerCallbackType and then give it options like TOCropViewControllerCallbackTypeDefault, TOCropViewControllerCallbackTypeDelegate, and TOCropViewControllerCallbackBlock so it's possible to control externally this behavior. :)
Let me know what you think!
Closing this off for now. If you'd like to pick it back up, let me know. Thanks! :)