Best way to clear a UITextField

For an IBOutlet UITextField, does it matter as far as memory management or other reasons how you clear the text value?

textFieldX.text = nil


textFieldX.text = @"";

In objective-c it is acceptable to message a nil object and @"" is a static NSString *. I'm not sure if every @"" points to the same object in memory or if it allocates a bunch of 1 byte null terminated strings.

Not a big deal, just thought I'd ask the community. Thanks.


  • Personally I would think less of the memory usage here and more on code-maintainability.

    To me, It makes sense that a label always has a string. In the future someone might try to append a labels value, save it in a database, wrap it in xml, etc. An empty NSString in this case makes much more sense to me that a 0x0.