<?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: Moving objects within an NSMutableArray</title>
	<atom:link href="http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/</link>
	<description>iCab related stuff; Mac, iPhone and Cocoa programming</description>
	<lastBuildDate>Fri, 10 Sep 2010 12:44:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Uday</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-1732</link>
		<dc:creator>Uday</dc:creator>
		<pubDate>Fri, 12 Feb 2010 00:59:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-1732</guid>
		<description>Still not showing up right. Basically, the checks for the source index row being smaller or greater than the destination index row are contained in both the &#039;insertObject&#039; and &#039;removeObjectAtIndex&#039; message statements, using the conditional operator &#039;?&#039;.</description>
		<content:encoded><![CDATA[<p>Still not showing up right. Basically, the checks for the source index row being smaller or greater than the destination index row are contained in both the &#8216;insertObject&#8217; and &#8216;removeObjectAtIndex&#8217; message statements, using the conditional operator &#8216;?&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uday</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-1730</link>
		<dc:creator>Uday</dc:creator>
		<pubDate>Thu, 11 Feb 2010 23:55:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-1730</guid>
		<description>Hmm, that didn&#039;t show up right. Retry:

[people insertObject:[people objectAtIndex:sourceIndexPath.row] atIndex:destinationIndexPath.row+(sourceIndexPath.rowdestinationIndexPath.row?1:0))];</description>
		<content:encoded><![CDATA[<p>Hmm, that didn&#8217;t show up right. Retry:</p>
<p>[people insertObject:[people objectAtIndex:sourceIndexPath.row] atIndex:destinationIndexPath.row+(sourceIndexPath.rowdestinationIndexPath.row?1:0))];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uday</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-1729</link>
		<dc:creator>Uday</dc:creator>
		<pubDate>Thu, 11 Feb 2010 23:53:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-1729</guid>
		<description>@Alexander
You&#039;re totally right, I posted an incomplete solution. Here is the code from one of my apps:

		[array insertObject:[people objectAtIndex:sourceIndexPath.row] atIndex:destinationIndexPath.row+(sourceIndexPath.rowdestinationIndexPath.row?1:0))];</description>
		<content:encoded><![CDATA[<p>@Alexander<br />
You&#8217;re totally right, I posted an incomplete solution. Here is the code from one of my apps:</p>
<p>		[array insertObject:[people objectAtIndex:sourceIndexPath.row] atIndex:destinationIndexPath.row+(sourceIndexPath.rowdestinationIndexPath.row?1:0))];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-1718</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Thu, 11 Feb 2010 14:36:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-1718</guid>
		<description>@Uday
Your solution has a problem when the &quot;from&quot; index is smaller than the &quot;to&quot; index. Here&#039;s an example:

The array has the following content:   
 0 1 2 3 4 5 6 

You want to move item  at index 2 to index 5. The first line of your code will result in the following array content (the content of index 2 (2) will be inserted at index 5):
 0 1 2 3 4 2 5 6

The second line of code will remove the element at 2+1 = 3, and now the array has the following content:
 0 1 2 4 2 5 6

But this is wrong. You&#039;ve deleted element 3 and the element 2 is now twice in the array.

Only if the &quot;to&quot; index is smaller than the &quot;from&quot; index, your solution would work.</description>
		<content:encoded><![CDATA[<p>@Uday<br />
Your solution has a problem when the &#8220;from&#8221; index is smaller than the &#8220;to&#8221; index. Here&#8217;s an example:</p>
<p>The array has the following content:<br />
 0 1 2 3 4 5 6 </p>
<p>You want to move item  at index 2 to index 5. The first line of your code will result in the following array content (the content of index 2 (2) will be inserted at index 5):<br />
 0 1 2 3 4 2 5 6</p>
<p>The second line of code will remove the element at 2+1 = 3, and now the array has the following content:<br />
 0 1 2 4 2 5 6</p>
<p>But this is wrong. You&#8217;ve deleted element 3 and the element 2 is now twice in the array.</p>
<p>Only if the &#8220;to&#8221; index is smaller than the &#8220;from&#8221; index, your solution would work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uday</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-1715</link>
		<dc:creator>Uday</dc:creator>
		<pubDate>Thu, 11 Feb 2010 11:06:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-1715</guid>
		<description>Alternatively, you could this:

[array insertObject:[array objectAtIndex:sourceIndexPath.row] atIndex:destinationIndexPath.row];
[array removeObjectAtIndex:(sourceIndexPath.row+1)];</description>
		<content:encoded><![CDATA[<p>Alternatively, you could this:</p>
<p>[array insertObject:[array objectAtIndex:sourceIndexPath.row] atIndex:destinationIndexPath.row];<br />
[array removeObjectAtIndex:(sourceIndexPath.row+1)];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-1709</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Wed, 10 Feb 2010 18:37:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-1709</guid>
		<description>@Cédric Luthi
No, I haven&#039;t filed this to Apple yet.</description>
		<content:encoded><![CDATA[<p>@Cédric Luthi<br />
No, I haven&#8217;t filed this to Apple yet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cédric Luthi</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-1708</link>
		<dc:creator>Cédric Luthi</dc:creator>
		<pubDate>Wed, 10 Feb 2010 16:39:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-1708</guid>
		<description>Thanks for sharing. This method should definitely be added to NSMutableArray. Have you filed a radar that we can dupe?</description>
		<content:encoded><![CDATA[<p>Thanks for sharing. This method should definitely be added to NSMutableArray. Have you filed a radar that we can dupe?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-1174</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Sun, 06 Dec 2009 10:00:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-1174</guid>
		<description>Cool! This is exactly what I was looking for. It&#039;s weird that some obvious functionality like this is not in the Interface!</description>
		<content:encoded><![CDATA[<p>Cool! This is exactly what I was looking for. It&#8217;s weird that some obvious functionality like this is not in the Interface!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
