How to override internal framework method in appli

2019-06-16 21:03发布

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条回答
贪生不怕死
2楼-- · 2019-06-16 21:27

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

查看更多
登录 后发表回答