Iphone – why does the uitextfield never return nil when it becomes first responder

iphonesdkuitextfield

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?

Best Answer

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.

Related Topic