Re: Checking NSTextFields stringValue
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.