10

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.

sage444
  • 5,661
  • 4
  • 33
  • 60
Mateusz Tylman
  • 271
  • 1
  • 2
  • 17

1 Answers1

0

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

szuniverse
  • 1,076
  • 4
  • 17
  • 32