How to group extension methods in Swift
Issue #11
Swift allows us to define more methods on existing class using extension.
1 | extension UIView { |
If you ‘re afraid of the naming conflict, you can prefix your methods, like
1 | view.abc_shake() |
Or a better way, reverse it 💃 , like
1 | view.animation.shake() |
This way, no more conflict and we make it clear that shake()
and fade()
belongs to animation category
Actually, animation and layout are properties in UIView extension. This may cause naming conflict, but the number of them is reduced
This is how it works
1 | extension UIView { |