Problems with converting a CGPoint to a string

Jason picture Jason · Jun 18, 2010 · Viewed 7.4k times · Source

I have been having problems with converting a CGPoint to a string. I have tried various methods, but this seems like the most promising but it still won't work. Any suggestions?

Here is my code:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject];
    coord = [touch locationInView:touch.view];  
    viewcoord.text = [NSString stringWithFormat:@"coordinates %@", coord.x, coord.y];

I get output but it just says "coordinates (null)" and I don't understand why...

Thanks

Answer

Dave DeLong picture Dave DeLong · Jun 18, 2010
viewcoord.text = [NSString stringWithFormat:@"coordinates %@", NSStringFromCGPoint(coord)];