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