NSLog C结构体是否可能(像CGRect或CGPoint)? [英] Is It Possible to NSLog C Structs (Like CGRect or CGPoint)?
本文介绍了NSLog C结构体是否可能(像CGRect或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));
有许多函数 CG结构到 NSString
s。它不工作的原因是因为%@
表示一个对象。 A CGPoint
是一个C结构(也是 CGRect
s和 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屋!
查看全文