uias / Tabman

™️ A powerful paging view controller with interactive indicator bars
https://uias.github.io/Tabman
MIT License
2.86k stars 237 forks source link

App Crash when calling TMBarButtonItem.allTargets because TMBarButtonInteractionController isn't Hashable. #517

Closed SuperTango closed 4 years ago

SuperTango commented 4 years ago

New Issue Checklist

Issue Description

This happens when using Mixpanel Tweaks, but can happen elsewhere.

The TMBarButtonInteractionController class isn't Hashable. However, it's added as a target to a TMBarButtonItem (i think). If the TMBarButtonItem's .allTargets property is fetched, the app will crash since UIKit is trying to cast TMBarButtonInteractionController to AnyHashable.

This is arguably a UIKit bug since the API for UIControl.addTarget only reuires that the target is Any?. However when calling .allTargets, UIKit crashes trying to cast the target to AnyHashable.

In any case, I've filed an apple radar, and asked on the forums (https://developer.apple.com/forums/thread/653574), but this doesn't seem like something that will get fixed soon.

By making TMBarButtonInteractionController Hashable, this bug goes away.

I've got a Pull request for this that I'll post in a few minutes.