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
2009-11-05 23:00:20
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
2009-11-05 23:05:14
Yes, I believe so.
luvieere
2009-11-05 23:05:58
i found an alternate way that works for me, i just use if([myTextField.text length] <= 0]){[self doStuff];}
nathanjosiah
2009-11-05 23:13:09
thank you for the answer :)
nathanjosiah
2009-11-05 23:13:39
What value do you expect to get and how do you test for it: put your if statement in the question.
luvieere
2009-11-05 23:14:06