I have a class where I have a private static constant:
class A {
private static let MY_CONSTANT = 1000
func setUp (xAxis:Charts.XAxis) {
...
}
}
Also in this class I have a method (setUp), inside of that method I create another class which uses that constant:
func setUp (xAxis:Charts.XAxis) {
class HistogramReadLenghtFormateer:IAxisValueFormatter {
func stringForValue(_ value: Double, axis: AxisBase?) -> String {
let lowIndex = Int(value) / A.MY_CONSTANT
let topIndex = (Int(value) + A.MY_CONSTANT) / A.MY_CONSTANT
return String(lowIndex) + "K" + "-" + String(topIndex) + "K"
}
}
let histogramReadLenghtFormateer = HistogramReadLenghtFormateer()
xAxis.labelPosition = .bottom
xAxis.labelFont = .systemFont(ofSize: 6)
xAxis.granularity = Double(A.MY_CONSTANT)
xAxis.labelCount = 7
xAxis.valueFormatter = histogramReadLenghtFormateer
}
Well, it seems that Xcode is ok with it, but AppCode complains:
Cannon Access to MY_CONSTANT. It is private in A
I know it's private but the class is defined inside of a method of the class A.
But it's even more intriguing that one compiler complain and the other one doesn't.
I guess it's because some settings of some kind. Any idea where to change this?