Is It Possible to NSLog C Structs (Like CGRect or CGPoint)? Is It Possible to NSLog C Structs (Like CGRect or CGPoint)? objective-c objective-c

Is It Possible to NSLog C Structs (Like CGRect or CGPoint)?


You can try this:

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

There are a number of functions provided by UIKit that convert the various CG structs into NSStrings. The reason it doesn't work is because %@ signifies an object. A CGPoint is a C struct (and so are CGRects and CGSizes).


There are a few functions like:

NSStringFromCGPoint  NSStringFromCGSize  NSStringFromCGRect  NSStringFromCGAffineTransform  NSStringFromUIEdgeInsets

An example:

NSLog(@"rect1: %@", NSStringFromCGRect(rect1));


NSLog(@"%@", CGRectCreateDictionaryRepresentation(rect));