<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Of BOOL and YES</title>
	<atom:link href="http://iPhoneDeveloperTips.com/objective-c/of-bool-and-yes.html/feed" rel="self" type="application/rss+xml" />
	<link>http://iPhoneDeveloperTips.com/objective-c/of-bool-and-yes.html</link>
	<description>Tips and Tricks for iPhone developers</description>
	<lastBuildDate>Thu, 29 Jul 2010 23:00:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Michel Colman</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/of-bool-and-yes.html/comment-page-1#comment-9138</link>
		<dc:creator>Michel Colman</dc:creator>
		<pubDate>Thu, 28 Jan 2010 07:30:04 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1422#comment-9138</guid>
		<description>By the way, it is also perfectly safe to use &quot;true&quot; and &quot;false&quot; instead of the ugly upper case &quot;YES&quot; and &quot;NO&quot;. You won&#039;t find a single YES or NO in my code, and it works just fine. Whenever setting a BOOL to true, the compiler automagically inserts a YES (implicit conversion of BOOL to bool). The resulting code is the same, maybe it will add a millisecond or so to my total compile time, and I guess a few bytes to the size of my code since YES and NO are shorter words, but otherwise it makes zero difference.</description>
		<content:encoded><![CDATA[<p>By the way, it is also perfectly safe to use &#8220;true&#8221; and &#8220;false&#8221; instead of the ugly upper case &#8220;YES&#8221; and &#8220;NO&#8221;. You won&#8217;t find a single YES or NO in my code, and it works just fine. Whenever setting a BOOL to true, the compiler automagically inserts a YES (implicit conversion of BOOL to bool). The resulting code is the same, maybe it will add a millisecond or so to my total compile time, and I guess a few bytes to the size of my code since YES and NO are shorter words, but otherwise it makes zero difference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michel Colman</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/of-bool-and-yes.html/comment-page-1#comment-9137</link>
		<dc:creator>Michel Colman</dc:creator>
		<pubDate>Thu, 28 Jan 2010 07:21:02 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1422#comment-9137</guid>
		<description>It is perfectly safe to use
bool b = myBOOL;
and
myBOOL = b;

These are exactly equivalent to your complicated question mark constructions. For example:

bool b = 3.141592654;
will set b to true. Conversion of anything to bool will set it to true if the original was not zero, and to false otherwise. No need to use &quot;? true: false&quot; because that&#039;s what a conversion to bool does by definition.

In the other direction, a bool will always be converted to 0 or 1, which corresponds to NO and YES in the BOOL type, so no worries there, either.

An &quot;if&quot; condition is also implicitly converted to bool, so the same applies there.

The only thing you should avoid, is explicitly comparing to YES.</description>
		<content:encoded><![CDATA[<p>It is perfectly safe to use<br />
bool b = myBOOL;<br />
and<br />
myBOOL = b;</p>
<p>These are exactly equivalent to your complicated question mark constructions. For example:</p>
<p>bool b = 3.141592654;<br />
will set b to true. Conversion of anything to bool will set it to true if the original was not zero, and to false otherwise. No need to use &#8220;? true: false&#8221; because that&#8217;s what a conversion to bool does by definition.</p>
<p>In the other direction, a bool will always be converted to 0 or 1, which corresponds to NO and YES in the BOOL type, so no worries there, either.</p>
<p>An &#8220;if&#8221; condition is also implicitly converted to bool, so the same applies there.</p>
<p>The only thing you should avoid, is explicitly comparing to YES.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/of-bool-and-yes.html/comment-page-1#comment-260</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Fri, 27 Feb 2009 16:14:49 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1422#comment-260</guid>
		<description>That works fine. Basically the compiler is comparing to zero, which is why you can do stuff like:

char* cp = some_address;
if (cp) {
// do something if cp != 0
}

if (!cp) {
// do something if cp == 0
}

So, the magic is in the ! operator. Given:

! value 

the result is of type int and is the &quot;logical negation&quot; of the value:

0 if value is nonzero;
1 if value is 0.

You can also say that the expression:

! value

is equivalent to:

(0 == value)

Notice that this explicitly avoids comparing with YES (or 1), which was the main point of my original note.

HTH!</description>
		<content:encoded><![CDATA[<p>That works fine. Basically the compiler is comparing to zero, which is why you can do stuff like:</p>
<p>char* cp = some_address;<br />
if (cp) {<br />
// do something if cp != 0<br />
}</p>
<p>if (!cp) {<br />
// do something if cp == 0<br />
}</p>
<p>So, the magic is in the ! operator. Given:</p>
<p>! value </p>
<p>the result is of type int and is the &#8220;logical negation&#8221; of the value:</p>
<p>0 if value is nonzero;<br />
1 if value is 0.</p>
<p>You can also say that the expression:</p>
<p>! value</p>
<p>is equivalent to:</p>
<p>(0 == value)</p>
<p>Notice that this explicitly avoids comparing with YES (or 1), which was the main point of my original note.</p>
<p>HTH!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: secretsquirrel</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/of-bool-and-yes.html/comment-page-1#comment-258</link>
		<dc:creator>secretsquirrel</dc:creator>
		<pubDate>Fri, 27 Feb 2009 04:14:55 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1422#comment-258</guid>
		<description>a question: 
in objective-c and iphone development, 
do both BOOL and bool allow setting with ! to toggle to the opposite?


example:
myBOOL = !myBOOL;
newBOOL = !myBOOL;

and so on.

can i pass a message to a method with !myBOOL?</description>
		<content:encoded><![CDATA[<p>a question:<br />
in objective-c and iphone development,<br />
do both BOOL and bool allow setting with ! to toggle to the opposite?</p>
<p>example:<br />
myBOOL = !myBOOL;<br />
newBOOL = !myBOOL;</p>
<p>and so on.</p>
<p>can i pass a message to a method with !myBOOL?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pRAMOD</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/of-bool-and-yes.html/comment-page-1#comment-228</link>
		<dc:creator>pRAMOD</dc:creator>
		<pubDate>Fri, 13 Feb 2009 05:04:36 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1422#comment-228</guid>
		<description>Good post......most usefull !!</description>
		<content:encoded><![CDATA[<p>Good post&#8230;&#8230;most usefull !!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adolfo</title>
		<link>http://iPhoneDeveloperTips.com/objective-c/of-bool-and-yes.html/comment-page-1#comment-172</link>
		<dc:creator>adolfo</dc:creator>
		<pubDate>Sat, 17 Jan 2009 07:43:27 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=1422#comment-172</guid>
		<description>Great post, man.  Concise and very useful.  It&#039;ll probably save me hours of frustrating debugging in the future.</description>
		<content:encoded><![CDATA[<p>Great post, man.  Concise and very useful.  It&#8217;ll probably save me hours of frustrating debugging in the future.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
