views:

149

answers:

1

when i make my textfield become first responder, the text field never returns nil, even if i force it to be nil by myTextField.text = nil; as soon as i comment out the "[myTextField becomeFirstResponder];" the text field is able to return nil. anybody have any idea why?

A: 

Becoming first responder initializes the internal NSString that holds the text you type to an empty string: @"", thus no longer nil. Being firstResponder is a persistent action, in order to always have a valid NSString in there when the user begins to type.

luvieere
so if i wanted to get the default value of the text field once the it becomes first responder, would it just be literally: @""?
nathanjosiah
Yes, I believe so.
luvieere
i found an alternate way that works for me, i just use if([myTextField.text length] <= 0]){[self doStuff];}
nathanjosiah
thank you for the answer :)
nathanjosiah
What value do you expect to get and how do you test for it: put your if statement in the question.
luvieere