<?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: Adding firstObject to NSArray</title>
	<atom:link href="http://troybrant.net/blog/2010/02/adding-firstobject-to-nsarray/feed/" rel="self" type="application/rss+xml" />
	<link>http://troybrant.net/blog/2010/02/adding-firstobject-to-nsarray/</link>
	<description>Mistakes and learnings of an iPhone developer</description>
	<lastBuildDate>Fri, 09 Dec 2011 12:26:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dave</title>
		<link>http://troybrant.net/blog/2010/02/adding-firstobject-to-nsarray/comment-page-1/#comment-2043</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Mon, 15 Nov 2010 23:13:58 +0000</pubDate>
		<guid isPermaLink="false">http://troybrant.net/blog/?p=66#comment-2043</guid>
		<description>Kent Beck in his implementation patterns book talks about symmetry, matching levels of abstractions throughout your code, so if there&#039;s a lastObject, it makes sense there should be should be a firstObject too. There have been edge cases when I&#039;ve used [array objectAtIndex: 0] in certain situations during coding and thought it was &#039;ugly&#039; and didn&#039;t fit in with the level of abstraction in my code at the time; perhaps it&#039;s a style thing, a level-of-abstraction thing, who knows - maybe there should be methods [array head] and [array tail]</description>
		<content:encoded><![CDATA[<p>Kent Beck in his implementation patterns book talks about symmetry, matching levels of abstractions throughout your code, so if there&#8217;s a lastObject, it makes sense there should be should be a firstObject too. There have been edge cases when I&#8217;ve used [array objectAtIndex: 0] in certain situations during coding and thought it was &#8216;ugly&#8217; and didn&#8217;t fit in with the level of abstraction in my code at the time; perhaps it&#8217;s a style thing, a level-of-abstraction thing, who knows &#8211; maybe there should be methods [array head] and [array tail]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Foo</title>
		<link>http://troybrant.net/blog/2010/02/adding-firstobject-to-nsarray/comment-page-1/#comment-239</link>
		<dc:creator>Foo</dc:creator>
		<pubDate>Sat, 10 Apr 2010 19:06:02 +0000</pubDate>
		<guid isPermaLink="false">http://troybrant.net/blog/?p=66#comment-239</guid>
		<description>@Jill:

Well, at first glance your statement appears to be valid.
Yet upon further inspection you should notice a subtle difference between

[array objectAtIndex:0];
[array firstObject];

Try to run those two on an empty array.
Result: The former method will throw an exception whereas the latter (category) method does not, returning nil instead. Just like Apple&#039;s &quot;[array lastObject]&quot; uses to do it.

Summing up: [array objectAtIndex:0] != [array firstObject] and by that in no way &quot;pointless&quot;.</description>
		<content:encoded><![CDATA[<p>@Jill:</p>
<p>Well, at first glance your statement appears to be valid.<br />
Yet upon further inspection you should notice a subtle difference between</p>
<p>[array objectAtIndex:0];<br />
[array firstObject];</p>
<p>Try to run those two on an empty array.<br />
Result: The former method will throw an exception whereas the latter (category) method does not, returning nil instead. Just like Apple&#8217;s &#8220;[array lastObject]&#8221; uses to do it.</p>
<p>Summing up: [array objectAtIndex:0] != [array firstObject] and by that in no way &#8220;pointless&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jill</title>
		<link>http://troybrant.net/blog/2010/02/adding-firstobject-to-nsarray/comment-page-1/#comment-61</link>
		<dc:creator>Jill</dc:creator>
		<pubDate>Mon, 22 Feb 2010 04:00:56 +0000</pubDate>
		<guid isPermaLink="false">http://troybrant.net/blog/?p=66#comment-61</guid>
		<description>There&#039;s a reason there&#039;s no &quot;firstObject&quot;:  It&#039;s not needed.
Object #0 *ALWAYS* is the 1st object.
  
Doing all that extract/unneeded work... to create your own firstObject is like saying:
The first book on that shelf is the first book.
  
Your code is an excellent example of &quot;categories&quot;... but used in a pointless way.
  
&quot;Category&quot; is a VERY powerful thing.  Use it as such.</description>
		<content:encoded><![CDATA[<p>There&#8217;s a reason there&#8217;s no &#8220;firstObject&#8221;:  It&#8217;s not needed.<br />
Object #0 *ALWAYS* is the 1st object.</p>
<p>Doing all that extract/unneeded work&#8230; to create your own firstObject is like saying:<br />
The first book on that shelf is the first book.</p>
<p>Your code is an excellent example of &#8220;categories&#8221;&#8230; but used in a pointless way.</p>
<p>&#8220;Category&#8221; is a VERY powerful thing.  Use it as such.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

