<?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: Fun with KVC</title>
	<atom:link href="http://www.noodlesoft.com/blog/2009/06/30/fun-with-kvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.noodlesoft.com/blog/2009/06/30/fun-with-kvc/</link>
	<description>On Mac OS X programming</description>
	<lastBuildDate>Sat, 07 Jan 2012 04:23:42 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Kirk Kerekes</title>
		<link>http://www.noodlesoft.com/blog/2009/06/30/fun-with-kvc/comment-page-1/#comment-42050</link>
		<dc:creator>Kirk Kerekes</dc:creator>
		<pubDate>Wed, 05 Aug 2009 20:27:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.noodlesoft.com/blog/?p=217#comment-42050</guid>
		<description>I would dispute the contention that these techniques are &quot;abuse&quot;, indeed I feel that they are now central to efficient, maintainable coding in Cocoa, and their virtuousness is implied by:

1. The very nature of object properties/accessors.
2. ObjC&#039;s &quot;Duck Typing&quot;
3. The existence of the KVC array and set &quot;operators&quot; 
4. The &quot;@&quot; prefix KVC override on the NS collection class clusters

BTW: makeObjectsPerformSelector:withObject: where the second param is a mutable collection is a fine way to get the return values of a method call.  It can be much faster (but much less obvious) than more conventional strategies for binning/indexing. 

Guy English&#039;s extensions to the concept are intriguing, but swizzling the behavior of KVC seems like a pretty hazardous notion for production code.</description>
		<content:encoded><![CDATA[<p>I would dispute the contention that these techniques are &#8220;abuse&#8221;, indeed I feel that they are now central to efficient, maintainable coding in Cocoa, and their virtuousness is implied by:</p>
<p>1. The very nature of object properties/accessors.<br />
2. ObjC&#8217;s &#8220;Duck Typing&#8221;<br />
3. The existence of the KVC array and set &#8220;operators&#8221;<br />
4. The &#8220;@&#8221; prefix KVC override on the NS collection class clusters</p>
<p>BTW: makeObjectsPerformSelector:withObject: where the second param is a mutable collection is a fine way to get the return values of a method call.  It can be much faster (but much less obvious) than more conventional strategies for binning/indexing. </p>
<p>Guy English&#8217;s extensions to the concept are intriguing, but swizzling the behavior of KVC seems like a pretty hazardous notion for production code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Burghardt</title>
		<link>http://www.noodlesoft.com/blog/2009/06/30/fun-with-kvc/comment-page-1/#comment-40461</link>
		<dc:creator>Aaron Burghardt</dc:creator>
		<pubDate>Wed, 01 Jul 2009 00:49:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.noodlesoft.com/blog/?p=217#comment-40461</guid>
		<description>Right, I didn&#039;t mean to imply it was equivalent, just sharing a nice complement that is useful for similar situations and something I would actually use.  Your point that the post was an indulgence wasn&#039;t lost.  I use KVC on arrays regularly, but you had some neat tricks.  Overall, a great read!</description>
		<content:encoded><![CDATA[<p>Right, I didn&#8217;t mean to imply it was equivalent, just sharing a nice complement that is useful for similar situations and something I would actually use.  Your point that the post was an indulgence wasn&#8217;t lost.  I use KVC on arrays regularly, but you had some neat tricks.  Overall, a great read!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mr_noodle</title>
		<link>http://www.noodlesoft.com/blog/2009/06/30/fun-with-kvc/comment-page-1/#comment-40459</link>
		<dc:creator>mr_noodle</dc:creator>
		<pubDate>Tue, 30 Jun 2009 23:56:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.noodlesoft.com/blog/?p=217#comment-40459</guid>
		<description>Guy: I was going to post your alloc/init example as well but couldn&#039;t recall where it would be used.

Paul/Aaron: I updated my post to clarify that this was much more of a random tangent. I also posted a more kosher way of doing a map function on an array.

Aaron: -makeObjectsPerformSelector here won&#039;t work for doing a map-like function where you need to collect the return values of the method call. It is the natural and correct replacement for abuse of -setValue:forKey: though.</description>
		<content:encoded><![CDATA[<p>Guy: I was going to post your alloc/init example as well but couldn&#8217;t recall where it would be used.</p>
<p>Paul/Aaron: I updated my post to clarify that this was much more of a random tangent. I also posted a more kosher way of doing a map function on an array.</p>
<p>Aaron: -makeObjectsPerformSelector here won&#8217;t work for doing a map-like function where you need to collect the return values of the method call. It is the natural and correct replacement for abuse of -setValue:forKey: though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Burghardt</title>
		<link>http://www.noodlesoft.com/blog/2009/06/30/fun-with-kvc/comment-page-1/#comment-40457</link>
		<dc:creator>Aaron Burghardt</dc:creator>
		<pubDate>Tue, 30 Jun 2009 23:11:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.noodlesoft.com/blog/?p=217#comment-40457</guid>
		<description>Not KVC, but another great option to avoid manually iterating over a collection is NSArray&#039;s and NSSet&#039;s makeObjectsPerformSelector: and makeObjectsPerformSelector:withObject:.  So, you could:

     [classes makeObjectsPerformSelector:@selector(@&quot;autorelease&quot;)];

or

     [people makeObjectsPerformSelector:@selector(@&quot;setCompany:&quot;) withObject:@&quot;Apple, Inc.&quot;];

     [people makeObjectsPerformSelector:@selector(@&quot;setDepartment:&quot;) withObject:dept];

The first example isn&#039;t as short as your KVC form, but feels less like it&#039;s abusing the frameworks.  It&#039;s also probably more efficient.</description>
		<content:encoded><![CDATA[<p>Not KVC, but another great option to avoid manually iterating over a collection is NSArray&#8217;s and NSSet&#8217;s makeObjectsPerformSelector: and makeObjectsPerformSelector:withObject:.  So, you could:</p>
<p>     [classes makeObjectsPerformSelector:@selector(@"autorelease")];</p>
<p>or</p>
<p>     [people makeObjectsPerformSelector:@selector(@"setCompany:") withObject:@"Apple, Inc."];</p>
<p>     [people makeObjectsPerformSelector:@selector(@"setDepartment:") withObject:dept];</p>
<p>The first example isn&#8217;t as short as your KVC form, but feels less like it&#8217;s abusing the frameworks.  It&#8217;s also probably more efficient.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.noodlesoft.com/blog/2009/06/30/fun-with-kvc/comment-page-1/#comment-40453</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Tue, 30 Jun 2009 22:16:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.noodlesoft.com/blog/?p=217#comment-40453</guid>
		<description>What you&#039;re pointing out is that KVC (in this case) is actually a form of &#039;map&#039; (from functional idioms). 

Now I&#039;m not sure I&#039;d actually want to use it as such, but I&#039;ve certainly missed map and it&#039;s cohorts at times. I think I&#039;d rather have a version that was intended for the purpose though, and didn&#039;t have the possibility of working differently at some point in the future.</description>
		<content:encoded><![CDATA[<p>What you&#8217;re pointing out is that KVC (in this case) is actually a form of &#8216;map&#8217; (from functional idioms). </p>
<p>Now I&#8217;m not sure I&#8217;d actually want to use it as such, but I&#8217;ve certainly missed map and it&#8217;s cohorts at times. I think I&#8217;d rather have a version that was intended for the purpose though, and didn&#8217;t have the possibility of working differently at some point in the future.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Guy</title>
		<link>http://www.noodlesoft.com/blog/2009/06/30/fun-with-kvc/comment-page-1/#comment-40449</link>
		<dc:creator>Guy</dc:creator>
		<pubDate>Tue, 30 Jun 2009 20:09:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.noodlesoft.com/blog/?p=217#comment-40449</guid>
		<description>NSArray *classes = [NSArray arrayWithObjects: [NSObject class], [NSObject class], [NSObject class], nil];

NSArray *instances = [classes valueForKeyPath: @&quot;alloc.init.autorelease&quot;];

I think Mike Ash showed me that first. He actually had a reason (well ... close enough) to want to do it but I forget what it was. And, yeah, my KVC stuff is more for the sake of interest than hard core use. Or, at least, don&#039;t swizzle valueForKeyPath: to do it but add another method that&#039;ll parse the queries. (and I really should fix up my blog ...)

- Guy</description>
		<content:encoded><![CDATA[<p>NSArray *classes = [NSArray arrayWithObjects: [NSObject class], [NSObject class], [NSObject class], nil];</p>
<p>NSArray *instances = [classes valueForKeyPath: @"alloc.init.autorelease"];</p>
<p>I think Mike Ash showed me that first. He actually had a reason (well &#8230; close enough) to want to do it but I forget what it was. And, yeah, my KVC stuff is more for the sake of interest than hard core use. Or, at least, don&#8217;t swizzle valueForKeyPath: to do it but add another method that&#8217;ll parse the queries. (and I really should fix up my blog &#8230;)</p>
<p>- Guy</p>
]]></content:encoded>
	</item>
</channel>
</rss>

