<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>David Beck&#039;s Blog &#187; Bindings</title>
	<atom:link href="http://davidbeckblog.com/tag/bindings/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidbeckblog.com</link>
	<description>The ramblings of an obsessed programmer</description>
	<lastBuildDate>Thu, 22 Jul 2010 18:01:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>NSTableView, NSArrayController and editing new rows</title>
		<link>http://davidbeckblog.com/2009/05/nstableview-nsarraycontroller-and-editing-new-rows/</link>
		<comments>http://davidbeckblog.com/2009/05/nstableview-nsarraycontroller-and-editing-new-rows/#comments</comments>
		<pubDate>Mon, 11 May 2009 06:42:59 +0000</pubDate>
		<dc:creator>David Beck</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bindings]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Objective C]]></category>

		<guid isPermaLink="false">http://davidbeckblog.com/?p=29</guid>
		<description><![CDATA[This is the only solution I could find that would allow you to automatically edit newly added rows when using bindings with an NSArrayController and an NSTableView.]]></description>
			<content:encoded><![CDATA[<p>Figured out a very nice solution to automatically edit new rows added by NSArrayControllers via bindings! I searched for a while and didn&#8217;t find any correct solutions, so I made my own.<br />
<span id="more-29"></span><br />
The problem is that any catch that you would normally use, including subclassing, wont work because NSArrayController defers changes until the next run loop.</p>
<p>I have a table which my object is the delegate of. The table is bound to the array controller. The array of the array controller is filled with <strong>NSMutableDictionarys</strong>.</p>
<p>So I have</p>
<p>Here&#8217;s what I did:</p>
<pre>- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{
	if([[[data objectAtIndex:[table selectedRow]] allKeys] count] == 0)
		[table editColumn:0 row:[table selectedRow] withEvent:nil select:YES];
}</pre>
<p>First we become the delegate of the table and implement the tableViewSelectionDidChange: method which is sent <em>after </em>the selection is changed. Then we check if the object (an NSMutableDictionary) has any keys set. If no keys are set, we assume that the row is new. This is different than if the keys were set to empty strings. editColumn:row:withEvent:select: scrolls to the row and column and starts editing the cell.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidbeckblog.com/2009/05/nstableview-nsarraycontroller-and-editing-new-rows/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
