iOS Question Objective C Library (Passing wrapped Object)

walterf25

Expert
Licensed User
Longtime User
Hi All, i'm working on trying to wrap parts of a Charts Library, so far i have been able to display a line graph by passing two arrays, x values and y values to the graph.

Now i'm trying to wrap the LineChartDataSet class of this library so i can have more control over the Line properties such as color, width etc.
I have the following in my header file:

LineChartDataSset:
//~shortname: iLineChartDataSet
//~objectwrapper: LineChartDataSet*
@interface iLineChartDataSet : B4IObjectWrapper

- (void) Initialize:(B4I*)bi :(NSString *)EventName :(NSString:)Label;

- (void)LineDashLenghts:(B4IArray */*double,1*/)linedashlenghts;
- (void)SetColor:(NSNumber *)LineColor;
@end

Now how would i be able to pass the iLineChartDataSet wrapper to a function in the iCharts class, i have the following function in my iCharts.m file
Objective-C:
//(NSObject *)dataset is just something i'm trying but is not working.
- (void)ChartData:(NSObject *)dataset[/COLOR] :(B4IArray *)xValues :(B4IArray *)yValues{
    NSLog(@"xValues count: %0.2lu", (unsigned long)xValues.objectsData.count);
    NSLog(@"yValues count: %0.2lu", (unsigned long)yValues.objectsData.count);
  
    NSMutableArray *values = [[NSMutableArray alloc] init];
    NSMutableArray *numArray = yValues.objectsData; //[[NSMutableArray alloc] init];
    //[numArray addObject:yValues];
    NSMutableArray *xxvals = xValues.objectsData; //[[NSMutableArray alloc] init];
    //[xxvals addObject:xValues];
  
    for (int i = 0; i < xxvals.count; i++){
        NSLog(@"before assigning values to chartDataEntry");
        [values addObject:[[ChartDataEntry alloc] initWithX:i y:[[numArray objectAtIndex:i]doubleValue]]];
        //[[[ChartDataEntry alloc] initWithX: i y:[numArray objectAtIndex:i]doubleValue]];
        NSLog(@"After assigning values to chartDataEntry");
    }
  
    LineChartDataSet *set1 = nil;
    if (OBJ.data.dataSetCount > 0){
        set1 = (LineChartDataSet *) OBJ.data.dataSets[0];
        [set1 replaceEntries:values];
        [OBJ.data notifyDataChanged];
        [OBJ notifyDataSetChanged];
    }else{
        set1 = [[LineChartDataSet alloc] initWithEntries:values label:@"DataSet 1"];
        //I want to be able to pass the iLineChartsDataSet to the above line, something like this
        //set1 = iLineChartsDataSet.objectsData
        set1.drawCirclesEnabled = NO;
        [set1 setColor:UIColor.blackColor];
        [set1 setCircleColor:UIColor.redColor];
        set1.lineWidth = 1.0;
        set1.circleRadius = 3.0;
        set1.drawCircleHoleEnabled = YES;
      
        NSMutableArray *dataSets = [[NSMutableArray alloc] init];
        [dataSets addObject:set1];
      
        LineChartData *data = [[LineChartData alloc] initWithDataSets:dataSets];
        OBJ.data = data;
    }
}

Hope this makes sense.
 
Top