Search code examples
iosshinobi

Cannot subclass SChartCrosshairTooltip


I'm trying to subclass SChartCrosshairTooltip with 2.2.1 version of Shinobi Chart Library:

#import <UIKit/UIKit.h>
#import <ShinobiCharts/SChartCrosshairTooltip.h>

@interface Tooltip : SChartCrosshairTooltip

@end

No matter what I do, I always get this error:

ShinobiCharts Trial 2.2.1/Demos/LineChart/ShinobiCharts.embeddedframework/ShinobiCharts.framework/Headers/SChartCrosshairTooltip.h:21:5: Unknown type name 'SChartCrosshairStyle'; did you mean 'SChartCrosshairTooltip'?

as if it was impossible to subclass the SChartCrosshairTooltip differently from what documentation says.

I cannot switch to newer versions of the library (now is 2.5.0), but I really need to customize the crosshair tooltip.


Solution

  • The reason that this isn't working is because SChartCrosshairStyle is forward-defined in SChartCrosshairTooltip. I think that you could get around this by adding an import for SChartCrosshairStyle:

    #import <UIKit/UIKit.h>
    #import <ShinobiCharts/SChartCrosshairStyle.h>
    #import <ShinobiCharts/SChartCrosshairTooltip.h>
    

    ...however, there are other forward definitions inside SChartCrosshairTooltip, so I suspect that you will get other unknown class issues.

    The recommended way is to use the common Shinobi header import:

    #import <ShinobiCharts/ShinobiChart.h>
    

    This will import all the relevant classes.