2

I made an NSMUtableArray of CGpoints and I stored them by subclassing as NSValue, but I cant get the values out. here I what I did.

 CGPoint graphPoint;
    NSMutableArray *pointValues = [[NSMutableArray alloc] init];

    for( int x =0;x<5; x++)
    {
    NSDictionary* xValue = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:x] forKey:@"X"];
    graphPoint.x =x;
    graphPoint.y = [CalculatorBrain runProgram: self.graphingPoint usingVariableValues:xValue];

    [pointValues addObject:[NSValue valueWithCGPoint:graphPoint]];

}

I tried using this to get the values but I just get null back

for( int x=0; x<5; x++) {
NSValue *val = [pointValues objectAtIndex:x];
CGPoint point = [val CGpointValue];
NSLog(@"Points = %@", point);
}
Terrel Gibson
  • 481
  • 1
  • 6
  • 21

1 Answers1

3

You can't print a CGPoint using the %@ format specifier, as it is not an object. Instead, use NSStringFromCGPoint():

NSLog(@"%@", NSStringFromCGPoint(myPoint));
Richard J. Ross III
  • 55,009
  • 24
  • 135
  • 201