<?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: A complete raw list of KVC accessor selector formats</title>
	<atom:link href="http://boredzo.org/blog/archives/2007-08-07/a-complete-raw-list-of-kvc-accessor-selector-formats/feed" rel="self" type="application/rss+xml" />
	<link>http://boredzo.org/blog/archives/2007-08-07/a-complete-raw-list-of-kvc-accessor-selector-formats</link>
	<description>The personal weblog of Peter Hosey.</description>
	<pubDate>Thu, 08 Jan 2009 22:50:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
		<item>
		<title>By: Petteri Kamppuri</title>
		<link>http://boredzo.org/blog/archives/2007-08-07/a-complete-raw-list-of-kvc-accessor-selector-formats#comment-233886</link>
		<dc:creator>Petteri Kamppuri</dc:creator>
		<pubDate>Wed, 26 Nov 2008 13:03:52 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2007-08-07/a-complete-raw-list-of-kvc-accessor-selector-formats#comment-233886</guid>
		<description>Okay, thanks. The &lt;code&gt;init&lt;/code&gt; case was what intrigued me the most. It's probably easy to get right in the class you're writing, but subclasses could break those assumptions, and using accessors might invoke subclass code when the subclass hasn't been inited. That's a good reason to stay away from accessors.

I haven't used accessors in &lt;code&gt;dealloc&lt;/code&gt; methods, but I haven't been as strict with &lt;code&gt;init&lt;/code&gt;s. I'll be from now on.</description>
		<content:encoded><![CDATA[<p>Okay, thanks. The <code>init</code> case was what intrigued me the most. It's probably easy to get right in the class you're writing, but subclasses could break those assumptions, and using accessors might invoke subclass code when the subclass hasn't been inited. That's a good reason to stay away from accessors.</p>
<p>I haven't used accessors in <code>dealloc</code> methods, but I haven't been as strict with <code>init</code>s. I'll be from now on.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2007-08-07/a-complete-raw-list-of-kvc-accessor-selector-formats#comment-233871</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Wed, 26 Nov 2008 09:51:44 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2007-08-07/a-complete-raw-list-of-kvc-accessor-selector-formats#comment-233871</guid>
		<description>&lt;p&gt;Petteri Kammpuri: Don't use property-access expressions in &lt;code&gt;init&lt;/code&gt; and &lt;code&gt;dealloc&lt;/code&gt; methods, because the property access will call your accessors.&lt;/p&gt;

&lt;p&gt;In the former case, you may not have completely initialized the object yet; in the latter case, you may have partially destructed it. If you have custom accessors that reply on other properties of your object, this may be a problem. And you can't say with 100% confidence that you will never, ever make a custom accessor for that property.&lt;/p&gt;

&lt;p&gt;So don't do it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;code&gt;init&lt;/code&gt; methods (including &lt;code&gt;initWithSomethingElse:&lt;/code&gt; methods), always assign the retained or copied object directly to the instance variable (in other words, &lt;code&gt;myObject = [newObject retain]&lt;/code&gt;, not &lt;code&gt;self.myObject = newObject&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;In &lt;code&gt;dealloc&lt;/code&gt; methods, always get the object directly from the instance variable before you send &lt;code&gt;release&lt;/code&gt; to it (in other words, &lt;code&gt;[myObject release]&lt;/code&gt;, not &lt;code&gt;[self.myObject release]&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;If you do write any custom accessor methods, they must, of course, directly access the instance variable. However, if an accessor for one property accesses another property, it should use property access for that.&lt;/li&gt;
&lt;li&gt;In any other method, always use property access, never direct access. You can use local variables if speed becomes a problem (for example, if profiling shows a lot of time spent in a getter), but don't worry about it until your profiler says otherwise.&lt;/li&gt;
&lt;/ul&gt;

</description>
		<content:encoded><![CDATA[<p>Petteri Kammpuri: Don't use property-access expressions in <code>init</code> and <code>dealloc</code> methods, because the property access will call your accessors.</p>
<p>In the former case, you may not have completely initialized the object yet; in the latter case, you may have partially destructed it. If you have custom accessors that reply on other properties of your object, this may be a problem. And you can't say with 100% confidence that you will never, ever make a custom accessor for that property.</p>
<p>So don't do it.</p>
<ul>
<li>In <code>init</code> methods (including <code>initWithSomethingElse:</code> methods), always assign the retained or copied object directly to the instance variable (in other words, <code>myObject = [newObject retain]</code>, not <code>self.myObject = newObject</code>).</li>
<li>In <code>dealloc</code> methods, always get the object directly from the instance variable before you send <code>release</code> to it (in other words, <code>[myObject release]</code>, not <code>[self.myObject release]</code>).</li>
<li>If you do write any custom accessor methods, they must, of course, directly access the instance variable. However, if an accessor for one property accesses another property, it should use property access for that.</li>
<li>In any other method, always use property access, never direct access. You can use local variables if speed becomes a problem (for example, if profiling shows a lot of time spent in a getter), but don't worry about it until your profiler says otherwise.</li>
</ul>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petteri Kamppuri</title>
		<link>http://boredzo.org/blog/archives/2007-08-07/a-complete-raw-list-of-kvc-accessor-selector-formats#comment-233868</link>
		<dc:creator>Petteri Kamppuri</dc:creator>
		<pubDate>Wed, 26 Nov 2008 09:21:06 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/archives/2007-08-07/a-complete-raw-list-of-kvc-accessor-selector-formats#comment-233868</guid>
		<description>Can you elaborate on your "Exception:" part? What do you mean exactly and what are the reasons behind the exception? Thanks! Btw. I found "How to work with a bound-to array" extremely useful.</description>
		<content:encoded><![CDATA[<p>Can you elaborate on your "Exception:" part? What do you mean exactly and what are the reasons behind the exception? Thanks! Btw. I found "How to work with a bound-to array" extremely useful.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

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