views:

443

answers:

2

I'm debugging some code and finding it difficult to see & track the values being entered by the iPhone's keyboard into a UITextField (and from the UIDatePicker.)

I would expect Arguments>self>textField>_text to reflect the value that was entered into the textField but it isn't. It show's a different value ($0.00 instead of $1.25 for instance). When I write the value out via NSLog(@"textField.text:%@", textField.text); it shows the correct $1.25 value. What gives?

I wonder if this might be related to the fact that the UITextField is still first responder and this code I'm debugging is in a "Save" button that is pressed immediately after entering data in said UITextField?!? If so, question remains, where is that data stored and how can I debug it? I have similar trouble with a UIDatePicker used in a similar situation to modify a UITextField's value.

Thanks!

+4  A: 

What you are asking is essentially;

How can I view private class data in the debugger and have it reflect what I expect?

The answers is basically that you can't. The _text field may be updated at a later date, or not used at all.

If you do want a way to debug what's entered in a UITextField you can consider using the textField:shouldChangeCharactersInRange in the delegate to print out characters are they're typed.

Andrew Grant
A: 

The debugger doesn't understand dot notation (textField.text). But remember properties are simply shorthand for method calls - so calling [textfield text] does the exact same thing. So if you want to see a textfield value in the debugger, just type:

po [textField text]
Kendall Helmstetter Gelner