I tried Nankea's solution, but it doesn't work for SwiftUI's View:
public protocol ViewExtension: View { }
extension View: ViewExtension { } // I don't know why this doesn't have to be public!
public extension ViewExtension {
/// Places an alphabetical index next to the view.
/// - Parameter style: A style to apply to the index.
/// - Returns: The view with the added index.
public func alphabeticalIndex(style: AlphabeticalIndexStyle = AlphabeticalIndexStyle.default) -> some View {
self.modifier(AlphabeticalIndex(style: style))
}
}
I get "Extension of protocol 'View' cannot have an inheritance clause" on the second line.
This REALLY needs to be fixed!
Topic:
Developer Tools & Services
SubTopic:
General
Tags: