1

假设我想知道那个 NSIndexPath 的部分和行。

这些我试过:

在此处输入图像描述

4

2 回答 2

7

You are encountering a couple of problems. The first problem - leading to the error "property 'row' not found on object..." - is probably due to using properties declared on an NSIndexPath category (row and section are in the UIKit Additions category). Sometimes lldb is weird about when it will accept dot syntax, this must be one of them. Another issue - and the cause of the "No Objective-C description available" message - is that you are using po to print a non-object type - those properties are NSIntegers which are primitive types. Remember that po stands for 'print object', so only use it on objects. The proper command to print other types is p.

Try this lldb command:

p (NSInteger) [indexPath row]

or

expr void NSLog(@"row = %d, section = %d", [indexPath row], [indexPath section])
于 2013-10-29T08:01:14.760 回答
3

p (NSUInteger)[indexPath row]

原因是调试器不知道返回类型,所以必须通过指定返回类型来指定它,它比强制转换多一点。根据返回类型,调试器可以确定其大小、符号、类(结构、整数、指针、浮点)以及在哪里查找该返回值...基于 ABI,ints如果返回,则将以一种形式返回注册,floats可能在另一个,通常在堆栈上的结构等。

所以简而言之,它知道从哪里获取数据,以及如果您提供返回类型,如何显示它。

于 2013-10-31T00:51:58.737 回答