• 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: "Jonathan E. Jackel" <email@hidden>
  • Date: Wed, 29 Oct 2003 14:37:19 -0500

> I want to check if some NSTextFields are empty. When i do
> If ([myTF stringValue] == @"")
> {
> // do sth.. E.g. Alert
> }
> If ([myTF2 stringValue] == @"")
> {
> // do sth.. E.g. Alert
> }
>
> I can simply tab through the fields and the value isn't @"" so
> that this is
> useless :/
>
> Any idea?
>

Don't use == on objects. Objects are pointers. You are asking whether the
stringValue is stored at the same address as @"". That will always return
false.

Instead use [[myTF stringValue] isEqualToString:@""].

Many objects have their own isEqualTo... method.

Jonathan
_______________________________________________
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: Re: Using NSImage/NSBitmapImageRep stuff in command line tools
  • Next by Date: NSScreenNumber
  • Previous by thread: Checking NSTextFields stringValue
  • Next by thread: Re: Checking NSTextFields stringValue
  • Index(es):
    • Date
    • Thread