<?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, 03 Feb 2012 21:00:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Ignacio R.</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-16579</link>
		<dc:creator>Ignacio R.</dc:creator>
		<pubDate>Fri, 14 Oct 2011 19:49:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-16579</guid>
		<description>Great! That helped me a lot, thank you for sharing</description>
		<content:encoded><![CDATA[<p>Great! That helped me a lot, thank you for sharing</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-13096</link>
		<dc:creator>David</dc:creator>
		<pubDate>Wed, 15 Jun 2011 22:37:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-13096</guid>
		<description>Fantastic, thanks for sharing!!!</description>
		<content:encoded><![CDATA[<p>Fantastic, thanks for sharing!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PaulG</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-11725</link>
		<dc:creator>PaulG</dc:creator>
		<pubDate>Fri, 29 Apr 2011 14:52:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-11725</guid>
		<description>Great solution. Made my life that much easier.</description>
		<content:encoded><![CDATA[<p>Great solution. Made my life that much easier.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boy</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-11284</link>
		<dc:creator>Boy</dc:creator>
		<pubDate>Sun, 17 Apr 2011 18:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-11284</guid>
		<description>Great work, thanks for sharing.</description>
		<content:encoded><![CDATA[<p>Great work, thanks for sharing.</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-9544</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Wed, 02 Mar 2011 21:41:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-9544</guid>
		<description>@loosy
Yes, you can reorder the rows programatically. Just look at the UITableView class, here you&#039;ll find the following methods you can use for this task...
  
  beginUpdates
  endUpdates
  insertSections:withRowAnimation:
  deleteSections:withRowAnimation:
  reloadSections:withRowAnimation:
  insertRowsAtIndexPaths:withRowAnimation:
  deleteRowsAtIndexPaths:withRowAnimation:
  reloadRowsAtIndexPaths:withRowAnimation:</description>
		<content:encoded><![CDATA[<p>@loosy<br />
Yes, you can reorder the rows programatically. Just look at the UITableView class, here you&#8217;ll find the following methods you can use for this task&#8230;</p>
<p>  beginUpdates<br />
  endUpdates<br />
  insertSections:withRowAnimation:<br />
  deleteSections:withRowAnimation:<br />
  reloadSections:withRowAnimation:<br />
  insertRowsAtIndexPaths:withRowAnimation:<br />
  deleteRowsAtIndexPaths:withRowAnimation:<br />
  reloadRowsAtIndexPaths:withRowAnimation:</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: loosy</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-9542</link>
		<dc:creator>loosy</dc:creator>
		<pubDate>Wed, 02 Mar 2011 21:07:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-9542</guid>
		<description>hi Alexander,

In table view can we move rows programmatically with animation instead using &quot;Re-ordering Control&quot; using manual. I really needs it in my application. 

I&#039;ve seen this functionality in the app:
http://www.grocerygadgets.com/how-grocery-gadgets-work.aspx

Any help will be appreciated.</description>
		<content:encoded><![CDATA[<p>hi Alexander,</p>
<p>In table view can we move rows programmatically with animation instead using &#8220;Re-ordering Control&#8221; using manual. I really needs it in my application. </p>
<p>I&#8217;ve seen this functionality in the app:<br />
<a href="http://www.grocerygadgets.com/how-grocery-gadgets-work.aspx" rel="nofollow">http://www.grocerygadgets.com/how-grocery-gadgets-work.aspx</a></p>
<p>Any help will be appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-9519</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Wed, 02 Mar 2011 06:49:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-9519</guid>
		<description>Great solution, thanks so much for this.

If anyone else came across the warning &#039;NSMutableArray&#039; may not respond to &#039;-moveObjectsFromIndex:toIndex:&#039; don&#039;t forget to #import &quot;MoveArray.h&quot; in your ViewController class!</description>
		<content:encoded><![CDATA[<p>Great solution, thanks so much for this.</p>
<p>If anyone else came across the warning &#8216;NSMutableArray&#8217; may not respond to &#8216;-moveObjectsFromIndex:toIndex:&#8217; don&#8217;t forget to #import &#8220;MoveArray.h&#8221; in your ViewController class!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hebbian</title>
		<link>http://www.icab.de/blog/2009/11/15/moving-objects-within-an-nsmutablearray/comment-page-1/#comment-4632</link>
		<dc:creator>Hebbian</dc:creator>
		<pubDate>Fri, 08 Oct 2010 18:00:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=105#comment-4632</guid>
		<description>[assetArray insertObject: object atIndex: row];
		if (draggedIndex &gt; row)
			[assetArray removeObjectAtIndex:draggedIndex+1];
		else 
			[assetArray removeObjectAtIndex:draggedIndex];</description>
		<content:encoded><![CDATA[<p>[assetArray insertObject: object atIndex: row];<br />
		if (draggedIndex &gt; row)<br />
			[assetArray removeObjectAtIndex:draggedIndex+1];<br />
		else<br />
			[assetArray removeObjectAtIndex:draggedIndex];</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-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>
</channel>
</rss>

