[英]How to view values in debugger?
In Xcode 6.3, how do I view the values of objects such as: 在Xcode 6.3中,如何查看对象的值,例如:
arrary count: myarray.count
myarray.count
count: myarray.count
TableView index: indexPath.item
TableView索引:
indexPath.item
These don't show up in the debugger and I don't know how to print them out into the console. 这些不会显示在调试器中,我也不知道如何将它们打印到控制台中。
The easiest way is to log
them to console using NSLog / println depending on which language you use. 最简单的方法是根据您使用的语言,使用NSLog / println将它们
log
到控制台。
In Objective-C: 在Objective-C中:
NSLog(@"My Array Count: %i", myarray.count");
In Swift: 在Swift中:
println("My Array Count: \(myarray.count)")
Same goes for indexPath.item
- you can print item, row, selection or even whole content of your cell, such as textLabel's text, the same way you print number of items in an array. indexPath.item
同样适用-您可以打印单元格的项目,行,选择内容甚至整个内容,例如textLabel的文本,就像打印数组中的项目数一样。
For more advanced way of accesing number of items in your memory (such as a count of an array), you can always use Apple's Instruments
application, and its build in Allocations
. 有关访问内存中项目数(例如数组的计数)的更高级方法,您始终可以使用Apple的
Instruments
应用程序及其内置的Allocations
。
From there you can track how many objects you have in your memory: 从那里,您可以跟踪您的内存中有多少个对象:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.