是有可能的NSLog C结构(像的CGRect或CGPoint)? [英] Is It Possible to NSLog C Structs (Like CGRect or CGPoint)?

查看:138
本文介绍了是有可能的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));

有许多功能<一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 NSStrings. The reason it doesn't work is because %@ signifies an object. A CGPoint is a C struct (and so are CGRects and CGSizes).

这篇关于是有可能的NSLog C结构(像的CGRect或CGPoint)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆