• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Checking NSTextFields stringValue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking NSTextFields stringValue


  • Subject: Re: Checking NSTextFields stringValue
  • From: Fritz Anderson <email@hidden>
  • Date: Wed, 29 Oct 2003 14:26:16 -0600

On 29 Oct 2003, at 12:18 PM, David Dauer wrote:

I want to check if some NSTextFields are empty. When i do
If ([myTF stringValue] == @"")
...
I can simply tab through the fields and the value isn't @"" so that this is
useless :/

Well, I don't quite understand what you mean by that last part, but I'll point out that [myTF stringValue] returns a pointer to an NSString, and @"" is a pointer to another NSString. The second NSString is empty. The first may be empty, but it's sure to be at a different address than the second NSString. So the "==" test will always be false (the pointers will always be different), no matter if the text field is empty or not.

You intend:

if ([[myTF stringValue] length] == 0)
or:
if ([[myTF stringValue] isEqualToString: @""])

-- F
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Checking NSTextFields stringValue (From: David Dauer <email@hidden>)

  • Prev by Date: DVD playback format?
  • Next by Date: Re: componentsSeparatedByString:
  • Previous by thread: Re: Checking NSTextFields stringValue
  • Next by thread: WebController
  • Index(es):
    • Date
    • Thread