SChartAnnotation verticalLineAtPosition with Swift


#1

Hi guys,

I’m following the tutorial about creating a range selector (http://www.shinobicontrols.com/blog/posts/2013/02/20/building-a-range-selector-with-shinobicharts-part-i). 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?

Cheers,

Max


#2

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:

SChartAnnotation.verticalLineAtPosition(...);

Regards,
Jan


#3

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

Cheers Jan!