UITextField.text property clear with nil?

Discussion in 'iOS Programming' started by nashyo, Feb 10, 2012.

  1. macrumors 6502

    nashyo

    Joined:
    Oct 1, 2010
    Location:
    Bristol
    #1
    Hi,

    For clearing the text property of a UITextField programmatically, is it best to write nameTextField.text = @""; or nameTextField.text = nil; //?

    I'm not sure if this is the reason why my app is not working properly. I'm still trying to debug.

    I've searched through the apple documentation and other forums, and there doesn't seem to be a straight answer anywhere.

    Thanks
    Rob
     
  2. macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #2
    The documentation says that the text property is a NSString and is nil by default. I have used the empty quote method on NSStrings in UILabels and don't know why it wouldn't work with a UITextField also. So, it seems both methods are fine.
     
  3. thread starter macrumors 6502

    nashyo

    Joined:
    Oct 1, 2010
    Location:
    Bristol
    #3
    Thanks for this.

    I don't have a problem with UILabels either. It's only the UITextFields that seem to cause a problem. I'll look into it.
     

Share This Page