<?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: Memory Management</title>
	<atom:link href="http://MobileDeveloperTips.com/objective-c/memory-management.html/feed" rel="self" type="application/rss+xml" />
	<link>http://MobileDeveloperTips.com/objective-c/memory-management.html</link>
	<description>iOS and Objective-C Tips, Tricks and Tutorials.</description>
	<lastBuildDate>Tue, 22 May 2012 11:53:47 -0500</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Lukasz</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-49707</link>
		<dc:creator>Lukasz</dc:creator>
		<pubDate>Mon, 16 May 2011 14:12:24 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-49707</guid>
		<description>If you declared retained property, you can make it even simpler:
self.str = nil;
It will release and set to nil in one step.</description>
		<content:encoded><![CDATA[<p>If you declared retained property, you can make it even simpler:<br />
self.str = nil;<br />
It will release and set to nil in one step.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Muchow</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-49702</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Mon, 16 May 2011 13:34:09 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-49702</guid>
		<description>Yes, that is a nice clean way to release and set to nil - that is a good example of where the comma operator is handy.</description>
		<content:encoded><![CDATA[<p>Yes, that is a nice clean way to release and set to nil &#8211; that is a good example of where the comma operator is handy.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shahil shah</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-49701</link>
		<dc:creator>shahil shah</dc:creator>
		<pubDate>Mon, 16 May 2011 13:26:31 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-49701</guid>
		<description>thanks :)

just a question:-

what if in dealloc, if we do :- 

[str release], str=nil;

is this correct ?</description>
		<content:encoded><![CDATA[<p>thanks :)</p>
<p>just a question:-</p>
<p>what if in dealloc, if we do :- </p>
<p>[str release], str=nil;</p>
<p>is this correct ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Muchow</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-34232</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Tue, 14 Dec 2010 23:31:23 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-34232</guid>
		<description>Yes, if you don&#039;t retain you should not have to release the variable.</description>
		<content:encoded><![CDATA[<p>Yes, if you don&#8217;t retain you should not have to release the variable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ZeroCool</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-34231</link>
		<dc:creator>ZeroCool</dc:creator>
		<pubDate>Tue, 14 Dec 2010 23:25:30 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-34231</guid>
		<description>Thanks for your helpful post!

If I didn&#039;t any retain operation to the str variable or a pointer which point to it, then I don&#039;t need to call [self setStr:nil], right?</description>
		<content:encoded><![CDATA[<p>Thanks for your helpful post!</p>
<p>If I didn&#8217;t any retain operation to the str variable or a pointer which point to it, then I don&#8217;t need to call [self setStr:nil], right?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Muchow</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-17490</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Fri, 18 Jun 2010 21:47:01 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-17490</guid>
		<description>Hey Paul, yes [self release] should do the trick.</description>
		<content:encoded><![CDATA[<p>Hey Paul, yes [self release] should do the trick.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-17489</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Fri, 18 Jun 2010 21:43:16 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-17489</guid>
		<description>John,

Thanks.  I understand that if the alloc fails there are no issues.  And, of course you would have to release any properties allocated.  My question had to do with the object itself.  Who is going to free that?  Should there be a [self release] (or whatever the notation might be) in the init if, during the init something bad happens?

Thanks</description>
		<content:encoded><![CDATA[<p>John,</p>
<p>Thanks.  I understand that if the alloc fails there are no issues.  And, of course you would have to release any properties allocated.  My question had to do with the object itself.  Who is going to free that?  Should there be a [self release] (or whatever the notation might be) in the init if, during the init something bad happens?</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Muchow</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-17469</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Fri, 18 Jun 2010 16:39:51 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-17469</guid>
		<description>Paul, here&#039;s my understanding - unless you specifically add code to an init method, the object would not be released. The general thought process is if alloc returns nil, then an init message will be sent to a nil object (legal in Objective-C), thus, ptr would be nil. 

If init could return nil, you would need to release any allocated memory inside the init method.

I think I&#039;ve got that correct, anyone else care to weigh in ?</description>
		<content:encoded><![CDATA[<p>Paul, here&#8217;s my understanding &#8211; unless you specifically add code to an init method, the object would not be released. The general thought process is if alloc returns nil, then an init message will be sent to a nil object (legal in Objective-C), thus, ptr would be nil. </p>
<p>If init could return nil, you would need to release any allocated memory inside the init method.</p>
<p>I think I&#8217;ve got that correct, anyone else care to weigh in ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-17468</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Fri, 18 Jun 2010 16:10:06 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-17468</guid>
		<description>In your example regarding initializing:

  TestClass *ptr = [[TestClass alloc] init];
 
  // Do something with the object
  if (ptr)
    ...

if alloc returns a allocated TestClass object, and you then call init on it, and init can&#039;t initialize and returns nil, what happened to the originally allocated object?  Did init deallocate it before returning nil?  No examples show this.</description>
		<content:encoded><![CDATA[<p>In your example regarding initializing:</p>
<p>  TestClass *ptr = [[TestClass alloc] init];</p>
<p>  // Do something with the object<br />
  if (ptr)<br />
    &#8230;</p>
<p>if alloc returns a allocated TestClass object, and you then call init on it, and init can&#8217;t initialize and returns nil, what happened to the originally allocated object?  Did init deallocate it before returning nil?  No examples show this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Muchow</title>
		<link>http://MobileDeveloperTips.com/objective-c/memory-management.html#comment-15945</link>
		<dc:creator>John Muchow</dc:creator>
		<pubDate>Thu, 27 May 2010 11:43:31 +0000</pubDate>
		<guid isPermaLink="false">http://iPhoneDeveloperTips.com/?p=46#comment-15945</guid>
		<description>Typically the accessor returns only a reference to an object, if you want to &quot;keep the object around&quot; the method that calls the accessor could follow this by sending a retain message to the value returned from the accessor, for example, [someObject retain].</description>
		<content:encoded><![CDATA[<p>Typically the accessor returns only a reference to an object, if you want to &#8220;keep the object around&#8221; the method that calls the accessor could follow this by sending a retain message to the value returned from the accessor, for example, [someObject retain].</p>
]]></content:encoded>
	</item>
</channel>
</rss>

