<?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>Big Bad Code &#187; Objective-C</title>
	<atom:link href="http://bigbadcode.com/category/objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigbadcode.com</link>
	<description>Don't blame me, I voted for Kodos</description>
	<lastBuildDate>Wed, 19 Aug 2009 21:49:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhone SDK Cocoa Objective-C Learnings</title>
		<link>http://bigbadcode.com/2008/10/13/iphone-sdk-cocoa-objective-c-learnings/</link>
		<comments>http://bigbadcode.com/2008/10/13/iphone-sdk-cocoa-objective-c-learnings/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 04:38:17 +0000</pubDate>
		<dc:creator>jbloom</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://bigbadcode.com/?p=170</guid>
		<description><![CDATA[I&#8217;ve been pretty heavily immersed in Apple Objective-C world lately and wanted to put down some of the things that I&#8217;ve learned. I&#8217;m going to post a little something when ever I find a few moments. 
Here&#8217;s the first:

It&#8217;s easier when someone else worries about memory management.

That being said, it&#8217;s not too hard to get [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been pretty heavily immersed in Apple Objective-C world lately and wanted to put down some of the things that I&#8217;ve learned. I&#8217;m going to post a little something when ever I find a few moments. </p>
<p>Here&#8217;s the first:</p>
<ol>
<li><strong>It&#8217;s easier when someone else worries about memory management.</strong></li>
</ol>
<p>That being said, it&#8217;s not too hard to get used to managing it yourself. The main rule to keep in mind is this.</p>
<blockquote><p>If you Alloc/Init the object you are responsible for managing the release of it.</p></blockquote>
<p>For example if you create a String like this:</p>

<div class="wp_syntax"><div class="code"><pre class="objc objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>myTestString <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> alloc<span style="color: #002200;">&#93;</span> 
                initWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;My Test String&quot;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Somewhere down the line you&#8217;ll need to make sure you release it, or you&#8217;ll be leaking memory.</p>

<div class="wp_syntax"><div class="code"><pre class="objc objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>myTestString release<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>If you&#8217;re worried about remembering the release you could also write the top part like this.</p>

<div class="wp_syntax"><div class="code"><pre class="objc objc" style="font-family:monospace;"><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>myTestString <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> alloc<span style="color: #002200;">&#93;</span>
               initWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;My Test String&quot;</span><span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>and then you won&#8217;t need to release it later on. </p>
<p>Hope that helps someone. </p>
]]></content:encoded>
			<wfw:commentRss>http://bigbadcode.com/2008/10/13/iphone-sdk-cocoa-objective-c-learnings/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
