SChartAnnotation verticalLineAtPosition with Swift


Hi guys,

I’m following the tutorial about creating a range selector ( This works great in a Swift only project as well, except for the ChartAnnotations, which I just can’t get to work.

For some reason I can’t call the SChartAnnotation constructor with verticalLineAtPosition. I only have annotationWithText for that class. Although that does work as expected, it isn’t necessarily what I was looking for.  :wink:

The same applies for the SChartAnnotationZooming which only grants access to the default constructors(empty, coder, frame).

Any clues?




Hi Maximillian,

Swift favours constructors over class methods. As a result, it uses string matching to convert class methods into constructors. Since our other class methods (‘verticalLineAtPosition’) don’t follow the convention ‘annotationWithXYZ:’ that the string matching magic isn’t picking these methods up.

These methods are still available as class methods which you can call:




D’oh! Didn’t see that one coming!

Cheers Jan!