<?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: Cocoa Tutorial: Using NSError to Great Effect</title>
	<atom:link href="http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/</link>
	<description>Taglines are for Windows programmers</description>
	<lastBuildDate>Tue, 09 Mar 2010 15:03:03 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/comment-page-1/#comment-1172</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Tue, 17 Mar 2009 15:20:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=89#comment-1172</guid>
		<description>&lt;p&gt;Yes, I normally use #define statements in the Prefix.pch&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Yes, I normally use #define statements in the Prefix.pch</p>]]></content:encoded>
	</item>
	<item>
		<title>By: minofifa</title>
		<link>http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/comment-page-1/#comment-1170</link>
		<dc:creator>minofifa</dc:creator>
		<pubDate>Tue, 17 Mar 2009 09:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=89#comment-1170</guid>
		<description>&lt;p&gt;Hi Marcus&lt;/p&gt;

&lt;p&gt;I noticed in several of your NSError article examples, you give the status code number a seemingly random value.  I&#039;m fairly sure this is simply to keep the examples short and sweet. I was wondering if, in your production code, you have some header that you include with a bunch of these error codes defined?  Is that the best approach?&lt;/p&gt;

&lt;p&gt;Thanks for the great blog.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Marcus</p>

<p>I noticed in several of your NSError article examples, you give the status code number a seemingly random value.  I&#8217;m fairly sure this is simply to keep the examples short and sweet. I was wondering if, in your production code, you have some header that you include with a bunch of these error codes defined?  Is that the best approach?</p>

<p>Thanks for the great blog.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/comment-page-1/#comment-408</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Mon, 07 Apr 2008 19:18:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=89#comment-408</guid>
		<description>&lt;p&gt;lodea,&lt;/p&gt;

&lt;p&gt;An opinion, no matter what you may think of it, can never be wrong.  I dislike try/catch blocks and consider them to be a bad design choice.  You are welcome to have your own opinion.&lt;/p&gt;

&lt;p&gt;As for my opinion -- an application should &lt;b&gt;never&lt;/b&gt; crash due to a bug that the developer is aware of.  Therefore if there is an exception that can be caught -- it should be caught.  The only time an application should crash is when something happens totally outside of the developer&#039;s expectations.  If the code is &lt;i&gt;throwing&lt;/i&gt; an exception then it is within the realm of expectation and therefore should be dealt with.&lt;/p&gt;

&lt;p&gt;Realize that this is an &lt;strong&gt;example&lt;/strong&gt; of using NSError.  It is not meant to be  perfect coding practice and that everyone must follow my lead.  It &lt;strong&gt;demonstrates&lt;/strong&gt; how to use the NSError object and the often complex subject of double indirection.  There are many weaknesses in the code that if corrected would cloud the message.&lt;/p&gt;

&lt;p&gt;As for your last point, not everything that Apple does is gold.  Just because they do something does not make it right.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>lodea,</p>

<p>An opinion, no matter what you may think of it, can never be wrong.  I dislike try/catch blocks and consider them to be a bad design choice.  You are welcome to have your own opinion.</p>

<p>As for my opinion &#8212; an application should <b>never</b> crash due to a bug that the developer is aware of.  Therefore if there is an exception that can be caught &#8212; it should be caught.  The only time an application should crash is when something happens totally outside of the developer&#8217;s expectations.  If the code is <i>throwing</i> an exception then it is within the realm of expectation and therefore should be dealt with.</p>

<p>Realize that this is an <strong>example</strong> of using NSError.  It is not meant to be  perfect coding practice and that everyone must follow my lead.  It <strong>demonstrates</strong> how to use the NSError object and the often complex subject of double indirection.  There are many weaknesses in the code that if corrected would cloud the message.</p>

<p>As for your last point, not everything that Apple does is gold.  Just because they do something does not make it right.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: lodea</title>
		<link>http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/comment-page-1/#comment-391</link>
		<dc:creator>lodea</dc:creator>
		<pubDate>Mon, 07 Apr 2008 00:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=89#comment-391</guid>
		<description>&lt;p&gt;You&#039;re completely wrong about exceptions and try/catch; when used correctly it is a far better mechanism than NSError, in general. However, for Cocoa, I agree that NSError is the best way to deal with errors. Exceptions are a huge pain when you don&#039;t have garbage collection, which is new in Objective-C and still not available on the iPhone. In Cocoa, exceptions should only be used to indicate programming bugs, in which case you want your program to crash as fast as possible, and you don&#039;t care about freeing memory properly. This is exactly what the Apple docs say on using NSError vs Exceptions.&lt;/p&gt;

&lt;p&gt;Also, the Cocoa library support you get for NSError is very good. Every Cocoa app should use NSError.&lt;/p&gt;

&lt;p&gt;One minor point - the convention seems to be that callers who don&#039;t care about the details of any errors are allowed to pass NULL for the *NSError pointer. I never assign to *error without checking if error is NULL first. I guess this only matters if you&#039;re writing code that might be called by someone else.&lt;/p&gt;

&lt;p&gt;Another minor point - you&#039;re checking if error was set to detect an error. But the examples I&#039;ve seen do this by checking for a special value returned by the method, usually nil or NO. From memory this is what the Apple docs recommend. I can&#039;t really see anything wrong with checking the error pointer, however.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You&#8217;re completely wrong about exceptions and try/catch; when used correctly it is a far better mechanism than NSError, in general. However, for Cocoa, I agree that NSError is the best way to deal with errors. Exceptions are a huge pain when you don&#8217;t have garbage collection, which is new in Objective-C and still not available on the iPhone. In Cocoa, exceptions should only be used to indicate programming bugs, in which case you want your program to crash as fast as possible, and you don&#8217;t care about freeing memory properly. This is exactly what the Apple docs say on using NSError vs Exceptions.</p>

<p>Also, the Cocoa library support you get for NSError is very good. Every Cocoa app should use NSError.</p>

<p>One minor point &#8211; the convention seems to be that callers who don&#8217;t care about the details of any errors are allowed to pass NULL for the *NSError pointer. I never assign to *error without checking if error is NULL first. I guess this only matters if you&#8217;re writing code that might be called by someone else.</p>

<p>Another minor point &#8211; you&#8217;re checking if error was set to detect an error. But the examples I&#8217;ve seen do this by checking for a special value returned by the method, usually nil or NO. From memory this is what the Apple docs recommend. I can&#8217;t really see anything wrong with checking the error pointer, however.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Marcus Zarra</title>
		<link>http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/comment-page-1/#comment-376</link>
		<dc:creator>Marcus Zarra</dc:creator>
		<pubDate>Sun, 06 Apr 2008 14:13:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=89#comment-376</guid>
		<description>&lt;p&gt;Icy,&lt;/p&gt;

&lt;p&gt;Yes it should be if (error) and it is correct in the project.  Thanks for catching the typo!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Icy,</p>

<p>Yes it should be if (error) and it is correct in the project.  Thanks for catching the typo!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: icy</title>
		<link>http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/comment-page-1/#comment-372</link>
		<dc:creator>icy</dc:creator>
		<pubDate>Sun, 06 Apr 2008 12:11:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=89#comment-372</guid>
		<description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;thanks a lot for this post. This is really some valuable information.
But shouldn&#039;t it be &quot;if (error)&quot; instead of &quot;if (!error)&quot; in the last listing?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi,</p>

<p>thanks a lot for this post. This is really some valuable information.
But shouldn&#8217;t it be &#8220;if (error)&#8221; instead of &#8220;if (!error)&#8221; in the last listing?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: tompa</title>
		<link>http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/comment-page-1/#comment-365</link>
		<dc:creator>tompa</dc:creator>
		<pubDate>Sun, 06 Apr 2008 06:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.cimgf.com/?p=89#comment-365</guid>
		<description>&lt;p&gt;Reading this code makes me laugh:&lt;/p&gt;

&lt;p&gt;if (!error) {
    [NSApp presentError:error];&lt;/p&gt;

&lt;p&gt;So, if not an error, then present the error.&lt;/p&gt;

&lt;p&gt;Thinking about it again, I just want to cry.&lt;/p&gt;

&lt;p&gt;/tompa&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Reading this code makes me laugh:</p>

<p>if (!error) {
    [NSApp presentError:error];</p>

<p>So, if not an error, then present the error.</p>

<p>Thinking about it again, I just want to cry.</p>

<p>/tompa</p>]]></content:encoded>
	</item>
</channel>
</rss>
