问题
Is there anyway to override internal framework method when subclassing in Swift? Ex. Superclass
public class BarChartRenderer: ChartDataRendererBase {
internal func drawDataSet(context context: CGContext, dataSet: BarChartDataSet, index: Int) {
...
}
}
and I want to override this method to draw differently that dataSet (iOS-Charts)
public class ESBarChartRenderer: BarChartRenderer {
overide func drawDataSet(context context: CGContext, dataSet: BarChartDataSet, index: Int) {
...
}
}
but when I'm trying to override Xcode gives me error:
Method does not override any method from its superclass
Because it's internal.
There is also one internal variable with I need access to and same as above Xcode can't see it.
回答1:
You should use the open
keyword instead of public
Check the the Access Control here: https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html
来源:https://stackoverflow.com/questions/35033301/how-to-override-internal-framework-method-in-application-outside-framework