• 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: Chris Hanson <email@hidden>
  • Date: Wed, 29 Oct 2003 14:16:16 -0600

On Oct 29, 2003, at 12:18 PM, David Dauer wrote:
I want to check if some NSTextFields are empty. When i do
If ([myTF stringValue] == @"")

Because there is no operator overloading in Objective-C, == is simple pointer comparison just like in C. So you're checking to see whether myTF's stringValue is the exact same object as @"".

You should be using [[myTextField stringValue] isEqualToString:@""] instead, just as for a plain C string you'd use (strcmp(s, "") == 0) and not (s == "").

-- Chris

--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Mac OS X Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
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: Generic application icon
  • Next by Date: Re: Getting NSImage of alert icon
  • Previous by thread: Re: Checking NSTextFields stringValue
  • Next by thread: Re: Checking NSTextFields stringValue
  • Index(es):
    • Date
    • Thread