Re: if ([[NSUserDefaults preferences] check box]==true) ?
Re: if ([[NSUserDefaults preferences] check box]==true) ?
- Subject: Re: if ([[NSUserDefaults preferences] check box]==true) ?
- From: Scott Ellsworth <email@hidden>
- Date: Sun, 9 Nov 2003 15:54:35 -0800
On Nov 9, 2003, at 3:18 AM, Wade Tregaskis wrote:
Also, if you are testing against true, *don't* use == to do it. C and
most of the code written in it assumes that any non-zero value is
true,
so you can trip yourself up and end-up in a situation where something
appears (to your code) to be neither true or false.
Perhaps we should apply some fuzzy logic to this, and just see if
things are > false. ;)
Are you basing this on experience, or just the hypothetical problem?
I'm aware of this problem, but have never in my life run into it, not
even once.
I have seen this many times. Most of the Access/VB programmers I know
store a true/false value as -1 or 0 in the db, often in a CHAR(2)
column. Most languages define their true macro as 1, so a "true" vb
column becomes a -1 value, which does not compare == the TRUE/true
macro.
The solution is the obvious one:
if (x) for c-like languages, if (x != false) for the wordy.
Scott
_______________________________________________
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.