Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 // :)

like image 968
Spanky Avatar asked Sep 25 '09 10:09

Spanky


1 Answers

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

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

The desktop Cocoa equivalent is NSStringFromPoint().

like image 65
Jens Ayton Avatar answered Sep 29 '22 03:09

Jens Ayton