<?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>Kernel Panic &#187; ObjC</title>
	<atom:link href="http://blog.epelaez.net/tag/objc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.epelaez.net</link>
	<description>~Keep It Simple</description>
	<lastBuildDate>Wed, 30 Jun 2010 17:11:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Orientation Lock</title>
		<link>http://blog.epelaez.net/05/orientation-lock/</link>
		<comments>http://blog.epelaez.net/05/orientation-lock/#comments</comments>
		<pubDate>Sat, 29 May 2010 16:00:54 +0000</pubDate>
		<dc:creator>Pelaez</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[ObjC]]></category>

		<guid isPermaLink="false">http://blog.epelaez.net/?p=804</guid>
		<description><![CDATA[This might become obsolete with 4.0, but I think it&#8217;s still worth a shot, if not to use it, at least to get an idea on how to do things.In short, this is what we are gonna do: We are gonna store a variable in the user defaults to store the locked orientation, or the [...]]]></description>
			<content:encoded><![CDATA[<p>This might become obsolete with 4.0, but I think it&#8217;s still worth a shot, if not to use it, at least to get an idea on how to do things.<span id="more-804"></span>In short, this is what we are gonna do:</p>
<ul>
<li>We are gonna store a variable in the user defaults to store the locked orientation, or the lack of lock.</li>
<li>Check the lock when the view controller wants to rotate.</li>
</ul>
<p>First, on first run, we need to store the variable on the defaults, so on the app delegate, we&#8217;ll do this:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSUserDefaults</span> standardUserDefaults<span style="color: #002200;">&#93;</span> objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Orientation&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #11740a; font-style: italic;">//Checks if there's an object for the key &quot;Orientation&quot;</span><br />
<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSUserDefaults</span> standardUserDefaults<span style="color: #002200;">&#93;</span> setInteger<span style="color: #002200;">:-</span><span style="color: #2400d9;">1</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Orientation&quot;</span><span style="color: #002200;">&#93;</span>;<span style="color: #11740a; font-style: italic;">//If there isn't, it stores the integer -1 under that key</span></div></td></tr></tbody></table></div>
<p>We are storing -1 because that&#8217;s gonna mean &#8220;unlocked&#8221;</p>
<p>Now, to lock the orientation, when the view controller that&#8217;s gonna lock it is in the orientation we want to lock, we&#8217;ll do this:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSUserDefaults</span> standardUserDefaults<span style="color: #002200;">&#93;</span> setInteger<span style="color: #002200;">:</span>orientation forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Orientation&quot;</span><span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>Now, on the view controllers we want to lock, we&#8217;ll override this selector like this:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span>shouldAutorotateToInterfaceOrientation<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>UIInterfaceOrientation<span style="color: #002200;">&#41;</span>interfaceOrientation<span style="color: #002200;">&#123;</span><br />
NSInteger orientation <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSUserDefaults</span> standardUserDefaults<span style="color: #002200;">&#93;</span> integerForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Orientation&quot;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #a61390;">return</span> <span style="color: #002200;">&#40;</span>interfaceOrientation <span style="color: #002200;">!=</span> UIInterfaceOrientationPortraitUpsideDown<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#40;</span>orientation <span style="color: #002200;">==</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">1</span> || orientation <span style="color: #002200;">==</span> interfaceOrientation<span style="color: #002200;">&#41;</span>;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>What that selector returns is ture for the supported orientations, so the first thing we&#8217;ll do is to check that interfaceOrientation is not upside down. Then, if orientation is -1, which means unlocked, return true, because we want it to rotate. And finally, if orientation is not -1, we&#8217;ll compare it to interfaceOrientation to allow it to be only in the locked orientation.</p>
<p>Aditionally, you can store orientation in an ivar, to avoid so many calls to the user defaults, but for the sake of it making sense, I didn&#8217;t do it here.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.epelaez.net/05/orientation-lock/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.epelaez.net/05/orientation-lock/&amp;title=Orientation+Lock" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.epelaez.net/05/orientation-lock/&amp;title=Orientation+Lock" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.epelaez.net/05/orientation-lock/&amp;t=Orientation+Lock" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22Orientation%20Lock%22&amp;body=Link: http://blog.epelaez.net/05/orientation-lock/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A This%20might%20become%20obsolete%20with%204.0%2C%20but%20I%20think%20it%27s%20still%20worth%20a%20shot%2C%20if%20not%20to%20use%20it%2C%20at%20least%20to%20get%20an%20idea%20on%20how%20to%20do%20things.In%20short%2C%20this%20is%20what%20we%20are%20gonna%20do%3A%0D%0A%0D%0A%09We%20are%20gonna%20store%20a%20variable%20in%20the%20user%20defaults%20to%20store%20the%20locked%20orientation%2C%20or%20the%20lack%20of%20lock.%0D%0A%09Check%20the%20loc" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Orientation+Lock+-+http://b2l.me/xrxed&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.epelaez.net/05/orientation-lock/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>UIColor Additions</title>
		<link>http://blog.epelaez.net/03/uicolor-additions/</link>
		<comments>http://blog.epelaez.net/03/uicolor-additions/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 01:59:35 +0000</pubDate>
		<dc:creator>Pelaez</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Release]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[ObjC]]></category>

		<guid isPermaLink="false">http://blog.epelaez.net/?p=789</guid>
		<description><![CDATA[Important Edit: Please redownload the file, as there were some important changes (that&#8217;s what happen when you don&#8217;t test it before ) Here are some small but useful additions to the UIColor class in UIKit. This is what it does: Adds a method to get a color from a Hex string (with either this #FFFFFF [...]]]></description>
			<content:encoded><![CDATA[<p>Important Edit: Please redownload the file, as there were some important changes (that&#8217;s what happen when you don&#8217;t test it before <img src='http://blog.epelaez.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> )</p>
<p>Here are some small but useful additions to the UIColor class in UIKit.<span id="more-789"></span></p>
<p>This is what it does:</p>
<ul>
<li>Adds a method to get a color from a Hex string (with either this #FFFFFF or this FFFFFF format).</li>
<li>Adds a method to get a color from an Hex string with custom alpha value.</li>
<li>Adds a method to get a color from a selector string.</li>
</ul>
<p>Here&#8217;s the download:</p>
<p><table style="border: 1px solid #CCC;" cellpadding="3" width="100%">
  <tr>
    <td width="35" style="vertical-align:top;">
      <a href="http://blog.epelaez.net/?file_id=22"><img src="http://blog.epelaez.net/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://blog.epelaez.net/wp-content/plugins/downloads-manager/img/icons/default.gif"></a>
    </td>
    <td>
      <b>File:</b> <a href="http://blog.epelaez.net/?file_id=22">UIColor Additions</a> <small>(1.95KB)</small><br />
      <b>added:</b> 19/03/2010 <br />
    </td>
  </tr>
</table></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.epelaez.net/03/uicolor-additions/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.epelaez.net/03/uicolor-additions/&amp;title=UIColor+Additions" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.epelaez.net/03/uicolor-additions/&amp;title=UIColor+Additions" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.epelaez.net/03/uicolor-additions/&amp;t=UIColor+Additions" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22UIColor%20Additions%22&amp;body=Link: http://blog.epelaez.net/03/uicolor-additions/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Important%20Edit%3A%20Please%20redownload%20the%20file%2C%20as%20there%20were%20some%20important%20changes%20%28that%27s%20what%20happen%20when%20you%20don%27t%20test%20it%20before%20%3AP%29%0D%0A%0D%0AHere%20are%20some%20small%20but%20useful%20additions%20to%20the%20UIColor%20class%20in%20UIKit.%0D%0A%0D%0AThis%20is%20what%20it%20does%3A%0D%0A%0D%0A%09Adds%20a%20method%20to%20get%20a%20color%20from%20a%20Hex%20string%20%28with%20either%20t" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=UIColor+Additions+-+http://b2l.me/wrxsd&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.epelaez.net/03/uicolor-additions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nil</title>
		<link>http://blog.epelaez.net/11/nil/</link>
		<comments>http://blog.epelaez.net/11/nil/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 02:38:22 +0000</pubDate>
		<dc:creator>Pelaez</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[nil]]></category>
		<category><![CDATA[ObjC]]></category>

		<guid isPermaLink="false">http://blog.epelaez.net/?p=675</guid>
		<description><![CDATA[Overview nil is ObjC&#8217;s null, which means that the pointer to the object doesn&#8217;t really point to anything. This is usually when you haven&#8217;t created the object. However, in ObjC, nil is much more useful than in other languages. In languages like Java, if an object is null and you try to do pretty much [...]]]></description>
			<content:encoded><![CDATA[<h4>Overview</h4>
<p>nil is ObjC&#8217;s null, which means that the pointer to the object doesn&#8217;t really point to anything. This is usually when you haven&#8217;t created the object.</p>
<p>However, in ObjC, nil is much more useful than in other languages. In languages like Java, if an object is null and you try to do pretty much anything with it, it will fail at runtime. nil is a lot more flexible.</p>
<p>In ObjC, you can send nil as a parameter for a selector(that&#8217;s how methods are called on ObjC, will use that from now on), receive nil from one, and even call  a selector on nil.</p>
<p><span id="more-675"></span></p>
<h4>Why is this useful?</h4>
<p>This is useful mostly to avoid checking if the object you got is nil every time you get an object, or before you call a selector on an object you are not sure. If you have some complex code which doesn&#8217;t always initialize objects before sending messages to them, you don&#8217;t have to worry on checking if the object is nil or not.</p>
<p>(You can even call something directly on &#8220;nil&#8221;, like this <code class="codecolorer text twitlight"><span class="text">[nil setText:aText];</span></code>, though it will give you a warning, and it isn&#8217;t useful at all <img src='http://blog.epelaez.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<p>Sometimes you&#8217;ll receive nil, and you don&#8217;t have to check that object before sending it to another object. For example, if you want to get a song lyrics and then send it to an UILabel, you can just send it without checking it, and it won&#8217;t crash.</p>
<p>Another cool thing you can do with nil, and objects in general, is using them as BOOLs. If you need to know if an object is nil (for example, before initializing it (under some circumstances)), you can do <code class="codecolorer text twitlight"><span class="text">if(anObject){}</span></code>, and if anObject is different from nil, it will happen, if the object is nil, it won&#8217;t.</p>
<h4><strong>What do I get when the selector I call should return something, but I call it on a nil object?</strong></h4>
<p>When the selector you call is supposed to return something, and the object you call it on is nil, it will return some defaults:</p>
<ul>
<li> nil if the return type is an object.</li>
<li>0/0.0 if the return type is an integer/float/double.</li>
<li>NO if the return type is BOOL.</li>
<li>If the return type is a struct, it will fill it&#8217;s fields with the above rules.</li>
</ul>
<h4>Things you should look for</h4>
<p>Releasing an object will not set it to nil. If you release an object that might get called in the future, and you are not gonna initialize it right away, you can do <code class="codecolorer text twitlight"><span class="text">anObject = nil;</span></code> to make sure that if you send a message to it, it doesn&#8217;t fail.</p>
<p>You shouldn&#8217;t take your nil habits to other languages, because chances are that the language won&#8217;t support it and it will fail <img src='http://blog.epelaez.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> .</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.epelaez.net/11/nil/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.epelaez.net/11/nil/&amp;title=nil" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.epelaez.net/11/nil/&amp;title=nil" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.epelaez.net/11/nil/&amp;t=nil" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22nil%22&amp;body=Link: http://blog.epelaez.net/11/nil/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Overview%0D%0Anil%20is%20ObjC%27s%20null%2C%20which%20means%20that%20the%20pointer%20to%20the%20object%20doesn%27t%20really%20point%20to%20anything.%20This%20is%20usually%20when%20you%20haven%27t%20created%20the%20object.%0D%0A%0D%0AHowever%2C%20in%20ObjC%2C%20nil%20is%20much%20more%20useful%20than%20in%20other%20languages.%20In%20languages%20like%20Java%2C%20if%20an%20object%20is%20null%20and%20you%20try%20to%20do%20pretty%20" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=nil+-+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.epelaez.net/11/nil/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful Documents</title>
		<link>http://blog.epelaez.net/08/useful-documents/</link>
		<comments>http://blog.epelaez.net/08/useful-documents/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 12:48:51 +0000</pubDate>
		<dc:creator>Pelaez</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[ObjC]]></category>
		<category><![CDATA[PDF]]></category>

		<guid isPermaLink="false">http://blog.epelaez.net/?p=316</guid>
		<description><![CDATA[This was a page, but I decided that it was too cluttered, so I decided to make it a post. Here are some PDFs that have been really helpful to me, I have not bought any books or anything. I did take a course on basic C, and I&#8217;m also being teached Java at school. [...]]]></description>
			<content:encoded><![CDATA[<p>This was a page, but I decided that it was too cluttered, so I decided to make it a post.</p>
<p>Here are some PDFs that have been really helpful to me, I have not bought any books or anything. I did take a course on basic C, and I&#8217;m also being teached Java at school.</p>
<ul>
<li><a title="ObjC" href="http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html" target="_blank">ObjC</a></li>
<li><a title="iPhone101" href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhone101/Articles/00_Introduction.html" target="_blank">iPhone101<br />
</a></li>
<li><a title="iPAPG" href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html" target="_blank">iPhone App Programming Guide</a></li>
</ul>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.epelaez.net/08/useful-documents/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.epelaez.net/08/useful-documents/&amp;title=Useful+Documents" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.epelaez.net/08/useful-documents/&amp;title=Useful+Documents" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.epelaez.net/08/useful-documents/&amp;t=Useful+Documents" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22Useful%20Documents%22&amp;body=Link: http://blog.epelaez.net/08/useful-documents/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A This%20was%20a%20page%2C%20but%20I%20decided%20that%20it%20was%20too%20cluttered%2C%20so%20I%20decided%20to%20make%20it%20a%20post.%0D%0A%0D%0AHere%20are%20some%20PDFs%20that%20have%20been%20really%20helpful%20to%20me%2C%20I%20have%20not%20bought%20any%20books%20or%20anything.%20I%20did%20take%20a%20course%20on%20basic%20C%2C%20and%20I%27m%20also%20being%20teached%20Java%20at%20school.%0D%0A%0D%0A%09ObjC%0D%0A%09iPhone101%0D%0A%0D%0A%09iPhone%20App" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Useful+Documents+-+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.epelaez.net/08/useful-documents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple App Template</title>
		<link>http://blog.epelaez.net/06/simple-app-template/</link>
		<comments>http://blog.epelaez.net/06/simple-app-template/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 12:52:16 +0000</pubDate>
		<dc:creator>Pelaez</dc:creator>
				<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Toolchain]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[ObjC]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://blog.epelaez.net/?p=245</guid>
		<description><![CDATA[I decided I needed a template App for the toolchain, so here it is. This is a template app that will make an empty app that does nothing but put your screen white. It&#8217;s made from a UIApplication subclass, a UIViewController subclass and a UIView subclass, so it&#8217;s pretty much ready for you to code [...]]]></description>
			<content:encoded><![CDATA[<p>I decided I needed a template App for the toolchain, so here it is.</p>
<p>This is a template app that will make an empty app that does nothing but put your screen white. It&#8217;s made from a UIApplication subclass, a UIViewController subclass and a UIView subclass, so it&#8217;s pretty much ready for you to code your own view, add your own methods and turn it into something.</p>
<p><table style="border: 1px solid #CCC;" cellpadding="3" width="100%">
  <tr>
    <td width="35" style="vertical-align:top;">
      <a href="http://blog.epelaez.net/?file_id=8"><img src="http://blog.epelaez.net/wp-content/plugins/downloads-manager/img/icons/default.gif" alt="http://blog.epelaez.net/wp-content/plugins/downloads-manager/img/icons/default.gif"></a>
    </td>
    <td>
      <b>File:</b> <a href="http://blog.epelaez.net/?file_id=8">App Template</a> <small>(3.31KB)</small><br />
      <b>added:</b> 06/06/2009 <br />
    </td>
  </tr>
</table></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.epelaez.net/06/simple-app-template/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.epelaez.net/06/simple-app-template/&amp;title=Simple+App+Template" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.epelaez.net/06/simple-app-template/&amp;title=Simple+App+Template" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.epelaez.net/06/simple-app-template/&amp;t=Simple+App+Template" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22Simple%20App%20Template%22&amp;body=Link: http://blog.epelaez.net/06/simple-app-template/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20decided%20I%20needed%20a%20template%20App%20for%20the%20toolchain%2C%20so%20here%20it%20is.%0D%0A%0D%0AThis%20is%20a%20template%20app%20that%20will%20make%20an%20empty%20app%20that%20does%20nothing%20but%20put%20your%20screen%20white.%20It%27s%20made%20from%20a%20UIApplication%20subclass%2C%20a%20UIViewController%20subclass%20and%20a%20UIView%20subclass%2C%20so%20it%27s%20pretty%20much%20ready%20for%20you%20to%20code" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Simple+App+Template+-+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.epelaez.net/06/simple-app-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ObjC class</title>
		<link>http://blog.epelaez.net/06/objc-class/</link>
		<comments>http://blog.epelaez.net/06/objc-class/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 22:45:32 +0000</pubDate>
		<dc:creator>Pelaez</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Toolchain]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[ObjC]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://blog.epelaez.net/?p=231</guid>
		<description><![CDATA[This is a &#8220;template&#8221; of a very basic ObjC class, with some things explained, you should copy it and paste it into a text editor to see it more clearly. 1234567891011121314151617181920212223242526272829//This USUALLY goes in a file called myClass.h #import @interface myClass:NSObject&#123; //&#34;myClass&#34; is the name of my class, NSObject is the superclass of my class [...]]]></description>
			<content:encoded><![CDATA[<p>This is a &#8220;template&#8221; of a very basic ObjC class, with some things explained, you should copy it and paste it into a text editor to see it more clearly.</p>
<p><span id="more-231"></span></p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">//This USUALLY goes in a file called myClass.h</span><br />
<span style="color: #6e371a;">#import</span><br />
<br />
<span style="color: #a61390;">@interface</span> myClass<span style="color: #002200;">:</span><span style="color: #400080;">NSObject</span><span style="color: #002200;">&#123;</span> <span style="color: #11740a; font-style: italic;">//&quot;myClass&quot; is the name of my class, NSObject is the superclass of my class</span><br />
<span style="color: #11740a; font-style: italic;">//Instance variables (These will be the object's attributes)</span><br />
<span style="color: #11740a; font-style: italic;">//Example:</span><br />
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #a61390;">string</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #11740a; font-style: italic;">//property declaration (Tells the compiler how to handle the variable, in this case, it will be read only)</span><br />
<span style="color: #a61390;">@property</span><span style="color: #002200;">&#40;</span>readonly<span style="color: #002200;">&#41;</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #a61390;">string</span>;<br />
<span style="color: #11740a; font-style: italic;">//declaration of methods</span><br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>init; <span style="color: #11740a; font-style: italic;">//Instance methods, you need to call these through an object of this class, notice the '-' sign</span><br />
<span style="color: #002200;">+</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>doSomething; <span style="color: #11740a; font-style: italic;">//Class methods, you call these directly, not through an object [myClass something], notice the '+' sign</span><br />
<span style="color: #a61390;">@end</span> <span style="color: #11740a; font-style: italic;">//end of the interface declaration</span><br />
<br />
<span style="color: #11740a; font-style: italic;">//This USUALLY goes in a file called myClass.m</span><br />
@implement myClass<br />
<br />
<span style="color: #11740a; font-style: italic;">//sytnesize tells the compiler to create the getter and setter methods depending on how you declared in @property, in this case it will only create a getter method</span><br />
<span style="color: #11740a; font-style: italic;">//If you want to create the getter and setter methods yourself, you can use @dynamic instead</span><br />
<span style="color: #a61390;">@synthesize</span> <span style="color: #a61390;">string</span>;<br />
<span style="color: #11740a; font-style: italic;">//implementation of declared methods</span><br />
<span style="color: #002200;">-</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>init<span style="color: #002200;">&#123;</span><br />
<span style="color: #11740a; font-style: italic;">//Some code</span><br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #002200;">+</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>doSomething<span style="color: #002200;">&#123;</span><br />
<span style="color: #11740a; font-style: italic;">//some code</span><br />
<span style="color: #002200;">&#125;</span><br />
<span style="color: #a61390;">@end</span> <span style="color: #11740a; font-style: italic;">//end of the implementation</span></div></td></tr></tbody></table></div>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.epelaez.net/06/objc-class/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.epelaez.net/06/objc-class/&amp;title=ObjC+class" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.epelaez.net/06/objc-class/&amp;title=ObjC+class" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.epelaez.net/06/objc-class/&amp;t=ObjC+class" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22ObjC%20class%22&amp;body=Link: http://blog.epelaez.net/06/objc-class/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A This%20is%20a%20%22template%22%20of%20a%20very%20basic%20ObjC%20class%2C%20with%20some%20things%20explained%2C%20you%20should%20copy%20it%20and%20paste%20it%20into%20a%20text%20editor%20to%20see%20it%20more%20clearly.%0D%0A%0D%0A%0D%0A%0D%0A%5Bcc%20lang%3D%22objc%22%5D%2F%2FThis%20USUALLY%20goes%20in%20a%20file%20called%20myClass.h%0D%0A%23import%0D%0A%0D%0A%40interface%20myClass%3ANSObject%7B%20%2F%2F%22myClass%22%20is%20the%20name%20of%20my%20class%2C%20" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=ObjC+class+-+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.epelaez.net/06/objc-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ObjC 1</title>
		<link>http://blog.epelaez.net/05/objc1/</link>
		<comments>http://blog.epelaez.net/05/objc1/#comments</comments>
		<pubDate>Fri, 29 May 2009 00:13:44 +0000</pubDate>
		<dc:creator>Pelaez</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[Toolchain]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[ObjC]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://blog.epelaez.net/?p=127</guid>
		<description><![CDATA[Personally, I had never used a language with a sintax like ObjC (if there&#8217;s another one with the same/similar sintax), so, comming from using C and Java, it was quite confusing. While ObjC uses C as a core, and accessing properties is quite similar as in other languages (object.property;), methods are a little bit different [...]]]></description>
			<content:encoded><![CDATA[<p>Personally, I had never used a language with a sintax like ObjC (if there&#8217;s another one with the same/similar sintax), so, comming from using C and Java, it was quite confusing.</p>
<p>While ObjC uses C as a core, and accessing properties is quite similar as in other languages (object.property;), methods are a little bit different from other languages I&#8217;ve used.<span id="more-127"></span></p>
<h2>Methods</h2>
<p>This is the kind of stuff that confused me the most:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">&#91;</span>something somethingElse<span style="color: #002200;">:</span>anotherThing more<span style="color: #002200;">:</span>Damn<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>So yea, it&#8217;s kinda like WTF?</p>
<p>Basically, what we are doing here is sending a message called &#8220;somethingElse&#8221;, with parameters &#8220;anotherThing&#8221; and &#8220;Damn&#8221;, to an object called &#8220;something&#8221;.</p>
<p>So let&#8217;s take a look at some actual code, this is the way we call an UIAlertView:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">UIAlertView <span style="color: #002200;">*</span>alert <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIAlertView alloc<span style="color: #002200;">&#93;</span> initWithTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hello&quot;</span> message<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hello World&quot;</span> delegate<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Close&quot;</span> otherButtonTitles<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#91;</span>alert show<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#91;</span>alert autorelease<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>Should be more understandable:</p>
<p>First, we are creating a new object called &#8220;alert&#8221;, of the type &#8220;UIAlertView&#8221;. Then we are initializing it, then showing it, and then tell it to be autoreleased. (Note, nil is ObjC&#8217;s null).</p>
<p>What [UIAlertView alloc] does is tell the OS to make some space in the RAM for a new object of the type UIAlertView.</p>
<p>Next, what initWithTitle:@&#8221;Hello&#8221;&#8230; does is initialize the alert with title &#8220;Hello&#8221;, message &#8220;Hello World&#8221;, etc. What [alert show] will do is to show the alert, and [alert autorelease] will autorelease when it&#8217;s not needed anymore.</p>
<p>If you go to the frameworks and find UIAlert.h, you&#8217;ll find that it has a method like this:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithTitle<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>title message<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>message delegate<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span> <span style="color: #11740a; font-style: italic;">/*&amp;lt;UIAlertViewDelegate&amp;gt;*/</span><span style="color: #002200;">&#41;</span>delegate cancelButtonTitle<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>cancelButtonTitle otherButtonTitles<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>otherButtonTitles, ...;</div></td></tr></tbody></table></div>
<p>There you can see where everything came from. In C, it would look like:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #a61390;">id</span> initWithTitle<span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>title, <span style="color: #400080;">NSString</span><span style="color: #002200;">*</span> message, <span style="color: #a61390;">id</span> <span style="color: #002200;">*</span>delegate, <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>cancelButtonTitle, <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>otherButtonTitles...<span style="color: #002200;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>That&#8217;s how methods are in ObjC, basically.</p>
<h2>Headers</h2>
<p>Now, usually, before using an object, you have to set it up for it to work/look as you want, then you use it, and then you release it, for example, we want to add a label that says Hello World in the middle of the screen:</p>
<div class="codecolorer-container objc default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #11740a; font-style: italic;">//We init the label with the a frame of 320 by 460, set up in the origin</span><br />
UILabel <span style="color: #002200;">*</span>helloLabel <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UILabel alloc<span style="color: #002200;">&#93;</span> initWithFrame<span style="color: #002200;">:</span>CGRectMake<span style="color: #002200;">&#40;</span>0.0f, 0.0f, 320.0f, 460.0f<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #11740a; font-style: italic;">//Here we set up some properties, like text, textColor and backgroundColor</span><br />
<span style="color: #002200;">&#91;</span>helloLabel setText<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hello World&quot;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#91;</span>helloLabel setTextColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor whiteColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#91;</span>helloLabel setBackgroundColor<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>UIColor clearColor<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #11740a; font-style: italic;">//Next we add it to the current view, and then we release it</span><br />
<span style="color: #002200;">&#91;</span>self.view addSubview<span style="color: #002200;">:</span>helloLabel<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#91;</span>helloLabel release<span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<p>Note that we are doing all the changes before adding it to as a subview, otherwise, the user could see as the properties are changing, and see the object being modified. We don&#8217;t want that.</p>
<p>Anyway, if you go to UILabel.h and look for &#8220;initWithFrame&#8221;, &#8220;setText&#8221;, &#8220;setTextColor&#8221;, etc., you won&#8217;t find those methods.</p>
<p>The first one is a method from UIView. If you don&#8217;t find it in the class you are using, it&#8217;s in one of it&#8217;s superclasses, when UILabel is declared, it&#8217;s declared like this: UILabel : UIView. That means it&#8217;s a subclass of UIView, and that it inherited some methods and properties of it (you probably knew this already if you had used OOP before).</p>
<p>The other methods are &#8220;setters&#8221;. If you go to UILabel.h, you&#8217;ll see something like: &#8220;@property(nonatomic, retain) NSString *text&#8221;. That means that ObjC will automatically create a getter method called &#8220;getText&#8221;, that will return the value of &#8220;text&#8221;, and a setter method called &#8220;setText&#8221;, which will take a NSSting as a parameter and will assign that string to &#8220;text&#8221;. There are other modifiers (besides nonatomic and retain), but I&#8217;ll come by them later.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.epelaez.net/05/objc1/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.epelaez.net/05/objc1/&amp;title=ObjC+1" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.epelaez.net/05/objc1/&amp;title=ObjC+1" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.epelaez.net/05/objc1/&amp;t=ObjC+1" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22ObjC%201%22&amp;body=Link: http://blog.epelaez.net/05/objc1/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A Personally%2C%20I%20had%20never%20used%20a%20language%20with%20a%20sintax%20like%20ObjC%20%28if%20there%27s%20another%20one%20with%20the%20same%2Fsimilar%20sintax%29%2C%20so%2C%20comming%20from%20using%20C%20and%20Java%2C%20it%20was%20quite%20confusing.%0D%0A%0D%0AWhile%20ObjC%20uses%20C%20as%20a%20core%2C%20and%20accessing%20properties%20is%20quite%20similar%20as%20in%20other%20languages%20%28object.property%3B%29%2C%20method" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=ObjC+1+-+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.epelaez.net/05/objc1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object Orientated Programming</title>
		<link>http://blog.epelaez.net/05/object-orientated-programming/</link>
		<comments>http://blog.epelaez.net/05/object-orientated-programming/#comments</comments>
		<pubDate>Thu, 28 May 2009 00:20:45 +0000</pubDate>
		<dc:creator>Pelaez</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[ObjC]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://blog.epelaez.net/?p=169</guid>
		<description><![CDATA[I thought it would be important for any readers of this blog (if there are any), to know what Object Orientated Programming is and to know at least the very basic of it. So here it is, a very quick overview on Object Orientated Programming (OOP) In OOP, you define classes, which are abstractions of [...]]]></description>
			<content:encoded><![CDATA[<p>I thought it would be important for any readers of this blog (if there are any), to know what Object Orientated Programming is and to know at least the very basic of it.</p>
<p>So here it is, a very quick overview on Object Orientated Programming (OOP)<span id="more-169"></span></p>
<p>In OOP, you define classes, which are abstractions of things, for example, an animal class (the most used example in my experience). Classes have attributes and methods, in this case, attributes would be size, color, etc., while methods would be run, jump, eat, etc.</p>
<p>However, &#8220;animal&#8221; is too abstract, so we could create a dog class that is a subclass of the animal class. It inherits most of the attributes (there are different kind of attributes, private and protected *) and methods from the animal class, but it implements some new ones.</p>
<p>When at runtime, we create objects from those classes, say, an object called &#8220;Lassie&#8221; that is of the dog kind.</p>
<p>When we create them, we have to set up some of their attributes, for that we use initializers or constructors. In ObjC, they are methods which&#8217;s names usually start with &#8220;initWith&#8230;&#8221;. They are usually quite clear of what they require.</p>
<p>*Kinds of attributes :</p>
<p>In ObjC, attributes are, by default, private. If you don&#8217;t specify it, other objects can&#8217;t access them.</p>
<p>To make them accessible, we use @property and @synthesize/@dynamic on the interface declaration.</p>
<p>There you have a really quick overview on how OOP works.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://blog.epelaez.net/05/object-orientated-programming/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://blog.epelaez.net/05/object-orientated-programming/&amp;title=Object+Orientated+Programming" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.epelaez.net/05/object-orientated-programming/&amp;title=Object+Orientated+Programming" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.epelaez.net/05/object-orientated-programming/&amp;t=Object+Orientated+Programming" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22Object%20Orientated%20Programming%22&amp;body=Link: http://blog.epelaez.net/05/object-orientated-programming/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A I%20thought%20it%20would%20be%20important%20for%20any%20readers%20of%20this%20blog%20%28if%20there%20are%20any%29%2C%20to%20know%20what%20Object%20Orientated%20Programming%20is%20and%20to%20know%20at%20least%20the%20very%20basic%20of%20it.%0D%0A%0D%0ASo%20here%20it%20is%2C%20a%20very%20quick%20overview%20on%20Object%20Orientated%20Programming%20%28OOP%29%0D%0A%0D%0AIn%20OOP%2C%20you%20define%20classes%2C%20which%20are%20abstractio" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Object+Orientated+Programming+-+&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://blog.epelaez.net/05/object-orientated-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
