<?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; oop</title>
	<atom:link href="http://blog.epelaez.net/tag/oop/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>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>
