<?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"
	>
<channel>
	<title>Comments on: And an answer: What to do if your table view shows the whole array in every row</title>
	<atom:link href="http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix/feed" rel="self" type="application/rss+xml" />
	<link>http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix</link>
	<description>The personal weblog of Peter Hosey.</description>
	<pubDate>Tue, 07 Oct 2008 18:10:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-167830</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Thu, 21 Feb 2008 08:34:30 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-167830</guid>
		<description>Eric Anderson:

&lt;blockquote&gt;&lt;p&gt;You could always write your own controller to correlate multiple arrays into keys.&lt;/p&gt;&lt;/blockquote&gt;

Sure. I'd like to see such a solution, but it doesn't scale unless you can make the binding variadic in IB (like enabled1, enabled2, etc.). That would require an IB plug-in; I don't know how much easier it is on Leopard, having not yet tried it, but doing it in Tiger is a PITA.

&lt;blockquote&gt;&lt;p&gt;OR&lt;br /&gt;Why not just use an object if you have two arrays that perfectly match up and just have an array of that object?&lt;/p&gt;&lt;/blockquote&gt;

That's what I suggested: “In my case, of course, this required creating a new model class for a key-value pair, to replace the parallel arrays of &lt;code&gt;NSString&lt;/code&gt;s.”</description>
		<content:encoded><![CDATA[<p>Eric Anderson:</p>
<blockquote cite="http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-"><p>You could always write your own controller to correlate multiple arrays into keys.</p>
</blockquote>
<p>Sure. I'd like to see such a solution, but it doesn't scale unless you can make the binding variadic in IB (like enabled1, enabled2, etc.). That would require an IB plug-in; I don't know how much easier it is on Leopard, having not yet tried it, but doing it in Tiger is a PITA.</p>
<blockquote cite="http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-"><p>OR<br />Why not just use an object if you have two arrays that perfectly match up and just have an array of that object?</p>
</blockquote>
<p>That's what I suggested: “In my case, of course, this required creating a new model class for a key-value pair, to replace the parallel arrays of <code>NSString</code>s.”</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Anderson</title>
		<link>http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-167827</link>
		<dc:creator>Eric Anderson</dc:creator>
		<pubDate>Thu, 21 Feb 2008 08:14:35 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-167827</guid>
		<description>You could always write your own controller to correlate multiple arrays into keys.
OR
Why not just use an object if you have two arrays that perfectly match up and just have an array of that object?</description>
		<content:encoded><![CDATA[<p>You could always write your own controller to correlate multiple arrays into keys.<br />
OR<br />
Why not just use an object if you have two arrays that perfectly match up and just have an array of that object?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jordy/Jediknil</title>
		<link>http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-147994</link>
		<dc:creator>Jordy/Jediknil</dc:creator>
		<pubDate>Mon, 10 Dec 2007 07:24:53 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-147994</guid>
		<description>But, sometimes it is useful to be able to use &lt;code&gt;NSString&lt;/code&gt;s as values. I added a similar function but called it &lt;code&gt;-string&lt;/code&gt;, to match &lt;code&gt;NSMutableString&lt;/code&gt;'s &lt;code&gt;-setString:&lt;/code&gt; method. This was for an app that really did only need a one-column table view. (Of course, yes, &lt;code&gt;-description&lt;/code&gt; does work as well, but I wanted &lt;em&gt;editable&lt;/em&gt; strings. For some reason. Hmm, maybe I &lt;em&gt;was&lt;/em&gt; breaking MVC there.)</description>
		<content:encoded><![CDATA[<p>But, sometimes it is useful to be able to use <code>NSString</code>s as values. I added a similar function but called it <code>-string</code>, to match <code>NSMutableString</code>'s <code>-setString:</code> method. This was for an app that really did only need a one-column table view. (Of course, yes, <code>-description</code> does work as well, but I wanted <em>editable</em> strings. For some reason. Hmm, maybe I <em>was</em> breaking MVC there.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-147943</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Mon, 10 Dec 2007 01:22:14 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-147943</guid>
		<description>&lt;blockquote&gt;No, there is nothing special about an array of strings failing. an array of any simple object type will fail. You need to have an array of model objects that support attributes.&lt;/blockquote&gt;

Right. That's what I figured out: The columns need to all specify various attributes of a single array of objects.

They &lt;em&gt;could&lt;/em&gt; be &lt;code&gt;NSString&lt;/code&gt;s, if you wanted to have two columns bound to &lt;code&gt;length&lt;/code&gt; and &lt;code&gt;description&lt;/code&gt;. They could be &lt;code&gt;NSCalendarDate&lt;/code&gt;s, which gives you rather more options, but those are “discouraged” since Leopard. They could be &lt;code&gt;NSURL&lt;/code&gt;s. (This should all be fine as long as the objects are immutable; mutable objects will fail because they are not guaranteed to mutate in the KVO-compliant ways, which may cause the data in your views to become stale.) For pretty much anything else, you need to roll your own model class.

The point that I learned is that you must have exactly one array of model objects (whatever their class)—no more.

&lt;blockquote&gt;And if you feel there is a need for a simple tableview and bindings example in the Cocoa Bindings documentation file a bug &lt;em&gt;now&lt;/em&gt; if you can.&lt;/blockquote&gt;

&lt;a href="http://homepage.mac.com/mmalc/CocoaExamples/controllers.html" rel="nofollow"&gt;mmalc has multiple examples.&lt;/a&gt; The problem that I had was that no documentation that I've seen has emphasized the importance of exactly one array of model objects.

I probably should file a bug about that, once I pin down a good place for Apple to put such a statement.</description>
		<content:encoded><![CDATA[<blockquote cite="http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-"><p>No, there is nothing special about an array of strings failing. an array of any simple object type will fail. You need to have an array of model objects that support attributes.</p>
</blockquote>
<p>Right. That's what I figured out: The columns need to all specify various attributes of a single array of objects.</p>
<p>They <em>could</em> be <code>NSString</code>s, if you wanted to have two columns bound to <code>length</code> and <code>description</code>. They could be <code>NSCalendarDate</code>s, which gives you rather more options, but those are “discouraged” since Leopard. They could be <code>NSURL</code>s. (This should all be fine as long as the objects are immutable; mutable objects will fail because they are not guaranteed to mutate in the KVO-compliant ways, which may cause the data in your views to become stale.) For pretty much anything else, you need to roll your own model class.</p>
<p>The point that I learned is that you must have exactly one array of model objects (whatever their class)—no more.</p>
<blockquote cite="http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-"><p>And if you feel there is a need for a simple tableview and bindings example in the Cocoa Bindings documentation file a bug <em>now</em> if you can.</p>
</blockquote>
<p><a href="http://homepage.mac.com/mmalc/CocoaExamples/controllers.html" rel="nofollow">mmalc has multiple examples.</a> The problem that I had was that no documentation that I've seen has emphasized the importance of exactly one array of model objects.</p>
<p>I probably should file a bug about that, once I pin down a good place for Apple to put such a statement.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Anguish</title>
		<link>http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-147892</link>
		<dc:creator>Scott Anguish</dc:creator>
		<pubDate>Sun, 09 Dec 2007 21:03:32 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2007-12-09/bindings-parallel-arrays-dont-mix#comment-147892</guid>
		<description>OK, first I clarified my last name... :-)

No, there is nothing special about an array of strings failing. an array of any simple object type will fail. You need to have an array of  model objects that support attributes.  From there you can delete all the extra stuff array/arraycontrollers.  I figured once you got over the hump of not being able to use simple arrays, you'd get there. :-)

And if you feel there is a need for a simple tableview and bindings example in the Cocoa Bindings documentation file a bug _now_ if you can.</description>
		<content:encoded><![CDATA[<p>OK, first I clarified my last name... :-)</p>
<p>No, there is nothing special about an array of strings failing. an array of any simple object type will fail. You need to have an array of  model objects that support attributes.  From there you can delete all the extra stuff array/arraycontrollers.  I figured once you got over the hump of not being able to use simple arrays, you'd get there. :-)</p>
<p>And if you feel there is a need for a simple tableview and bindings example in the Cocoa Bindings documentation file a bug _now_ if you can.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.193 seconds -->
