jdg / MBProgressHUD

MBProgressHUD + Customizations
http://www.bukovinski.com/
MIT License
16.01k stars 3.56k forks source link

HUDForView not exported to swift #557

Closed merkury closed 5 years ago

merkury commented 5 years ago

the function is not exported to swift (4.2): + (nullable MBProgressHUD *)HUDForView:(UIView *)view;

If renamed to i.e. "findHUDForView" it is accessible from swift by: MBProgressHUD.find(for: myViewParam)

Instead of renaming you can add the following (new line!) after the definition in the header file:

+ (nullable MBProgressHUD *)HUDForView:(UIView *)view NS_SWIFT_NAME(find(for:));

With this "annotation" the method can be called from swift 4.2 with: MBProgressHUD.find(for: myViewParam)

Originally posted by @merkury in https://github.com/jdg/MBProgressHUD/issues/450#issuecomment-450905923

Please look at the implementation of HUDForView. You will see, that it searches through all subviews for a running HUD. This means that it is not a constructor. It does something different and we need this method in swift. Reimplementing this in swift is also not possible because the hasFinished property is also not exported to swift either. See my comments in #543 and #450

matej commented 5 years ago

Adding a NS_SWIFT_NAME here sounds reasonable.

merkury commented 5 years ago

I can live with "MBProgressHUD(for: ...)" in swift.