user4951
user4951

Reputation: 33090

How to elegantly found the content of an NSIndexPath (and other cases) in Xcode 5?

Say I want to know the section and row of that NSIndexPath.

These I have tried:

enter image description here

Upvotes: 1

Views: 984

Answers (2)

Grady Player
Grady Player

Reputation: 14549

p (NSUInteger)[indexPath row]

and the reason is that the debugger doesn't know the return type so it must be specified by specifying the return type, it is a little bit more than a cast. from the return type the debugger can determine its size, signedness, class(struct, int, pointer, floating point), and where to look for that return value... based on the ABI, the ints will be returned in one kind if return register, floats likely in another, structs usually on the stack etc.

so in short it knows where to get the data, and how to display it if you provide the return type.

Upvotes: 3

Carl Veazey
Carl Veazey

Reputation: 18363

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])

Upvotes: 7

Related Questions