是有可能的NSLog C结构(像的CGRect或CGPoint)? [英] Is It Possible to NSLog C Structs (Like CGRect or CGPoint)?
问题描述
我希望能够调试C结构,而不必明确键入每一个他们包括物业。
I want to be able to debug C structures without having to explicitly type every property that they consist of.
即。我希望能够做这样的事:
i.e. I want to be able to do something like this:
CGPoint cgPoint = CGPointMake(0,0);
NSLog(@"%@",cgPoint);
显然,'%@'将无法正常工作,因此这个问题。
Obviously the '%@' won't work, hence the question.
推荐答案
您可以试试这个:
NSLog(@"%@", NSStringFromCGPoint(cgPoint));
有许多功能<一href=\"http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/doc/uid/TP40006894-CH3-SW34\">provided通过转换不同的CG结构为的NSString
取值的UIKit 。它不工作的原因是因为%@
表示的对象。 A CGPoint
是一个C结构(等都是的CGRect
和 CGSize
S)。
There are a number of functions provided by UIKit that convert the various CG structs into NSString
s. The reason it doesn't work is because %@
signifies an object. A CGPoint
is a C struct (and so are CGRect
s and CGSize
s).
这篇关于是有可能的NSLog C结构(像的CGRect或CGPoint)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!