I have a case where i read in the values from a CSV file in the server and then parse those file removing the commas. This data is to be plotted and hence I have to convert it into a CGFloat is there any posibble ways? Below is the code i was working with.
-(void)connection :(NSURLConnection *) connection didReceiveData:(NSData *)data{
[self serverConnect];
response = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *stripped1 = [response stringByReplacingOccurrencesOfString:@"\r" withString:@""];
NSMutableArray *rows = [NSMutableArray arrayWithArray:[stripped1 componentsSeparatedByString:@"\n"]];
NSMutableArray *contentArray = [NSMutableArray array];
NSArray *components;
for (int i=0;i<[rows count]; i++) {
if(i == 0 || [[rows objectAtIndex:i] isEqualToString:@""]){
continue;
}
components = [[rows objectAtIndex:i] componentsSeparatedByString:@","];
id x = [components objectAtIndex:0] ;
id y = [components objectAtIndex:1];
[contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x,@"x",y,@"y", nil]];
NSLog(@"Contents of myData: %@",contentArray);
}
self.scatterPlot = [[TUTSimpleScatterPlot alloc] initWithHostingView:_graphHostingView andData:contentArray];
[self.scatterPlot initialisePlot:0];
}
The content array has objects that are not CGFloat. The error happens to show up here
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
if ( [plot.identifier isEqual:@"mainplot"] )
{
NSValue *value = [self.graphData objectAtIndex:index];
**CGPoint point = [value CGPointValue];**
-[__NSCFDictionary CGPointValue]: unrecognized selector sent to instance 0x6b77c50′
The
contentArrayis anNSArrayofNSDictionaryobjects and the dictionary entry objects areNSString, notNSValue.Guessing that rt and uc are the x, y values of the point: