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