iphonecocoacocoa-touchcore-graphicsnslog

NSLog with CGPoint data


I have a CGPoint called point that is being assigned a touch:

UITouch *touch = [touches anyObject];

CGPoint point = [touch locationInView:self];

I want to get the x coordinate value into my console log:

NSLog(@"x: %s", point.x);

When I use this, log output for this is:

x: (null)

I have verified that point is not null when this is called using the debugger and variable watch.

Any help appreciated,

Thanks // :)


Solution

  • Actually, the real easiest way to log a CGPoint is:

    NSLog(@"%@", NSStringFromCGPoint(point));
    

    The desktop Cocoa equivalent is NSStringFromPoint().