<?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: Objective-C</title>
	<atom:link href="http://www.jasonrowland.com/2009/06/objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonrowland.com/2009/06/objective-c/</link>
	<description>Learning Mac, Ruby, iPhone, BlackBerry, Android, WinMobile</description>
	<lastBuildDate>Sat, 03 Sep 2011 21:27:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: jason</title>
		<link>http://www.jasonrowland.com/2009/06/objective-c/comment-page-1/#comment-4</link>
		<dc:creator>jason</dc:creator>
		<pubDate>Thu, 11 Jun 2009 20:52:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.jasonrowland.com/?p=30#comment-4</guid>
		<description>Thanks Martin for taking the time to help me understand these things better!  It&#039;s one of the reasons I&#039;m bothering to write these blog entries.</description>
		<content:encoded><![CDATA[<p>Thanks Martin for taking the time to help me understand these things better!  It&#8217;s one of the reasons I&#8217;m bothering to write these blog entries.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Pilkington</title>
		<link>http://www.jasonrowland.com/2009/06/objective-c/comment-page-1/#comment-3</link>
		<dc:creator>Martin Pilkington</dc:creator>
		<pubDate>Thu, 11 Jun 2009 13:47:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.jasonrowland.com/?p=30#comment-3</guid>
		<description>A few things to point out:

1. While this is somewhat nitpicking from an abstract point of view, in terms of implementation details you don&#039;t call methods on objects in Objective-C, but instead pass messages to them. It may seem nothing but it is a significantly different way of doing things as you can pass a message to an object that doesn&#039;t respond to it, but can&#039;t call a method on an object that doesn&#039;t respond to it which opens up all sorts of powerful features (similar to those found in Ruby or Python).

2. In terms of running code, connections are just instance variables. In terms the seemingly magical connection made between coding and runtime they are quite different to their opposite number: actions. Actions use the standard NSControl methods setTarget: and setAction: (remember Interface Builder is working with actual objects, not representations of them). Connections on the other hand and linking actual objects to a proxy object (your controller). When the NIB is loaded at runtime, this proxy object is replaced with the instance of your controller objects and then the instance variables are hooked up to the actual objects, either via accessor methods if they exist, or directly accessing the variable if they don&#039;t.

3. id is not equivalent to Object. NSObject is equivalent to Object. Saying something is Object or a subclass means that Object has to be one of the superclasses. This is the same with NSObject, but id allows objects that aren&#039;t subclasses of NSObject. In a nutshell, id is dynamic typing, NSObject is static typing. This often helps with compiler warnings. For example:

NSObject *myArray = [NSArray array];
[myArray count];

Would give a warning that NSObject may not respond to the method count, even though NSArray is a subclass of NSObject. However:

id myArray = [NSArray array];
[myArray count];

Would give no warning. The compiler just cares that some object somewhere responds to count and trusts the object to handle the message if it doesn&#039;t (either by discarding it or forwarding it to another object). It also helps get rid of generics or the need for casting (you&#039;ll notice that all collection classes in cocoa use id rather than NSObject).

4. Obviously this doesn&#039;t help on the iPhone, but if you were to ever program for the Mac there is a class in Foundation called NSSound which would simplify your sound code to:

[[NSSound soundNamed:@&quot;filename&quot;] play];

Unfortunately this is one of the many classes that is missing from the iPhone.

Anyway hope this helps</description>
		<content:encoded><![CDATA[<p>A few things to point out:</p>
<p>1. While this is somewhat nitpicking from an abstract point of view, in terms of implementation details you don&#8217;t call methods on objects in Objective-C, but instead pass messages to them. It may seem nothing but it is a significantly different way of doing things as you can pass a message to an object that doesn&#8217;t respond to it, but can&#8217;t call a method on an object that doesn&#8217;t respond to it which opens up all sorts of powerful features (similar to those found in Ruby or Python).</p>
<p>2. In terms of running code, connections are just instance variables. In terms the seemingly magical connection made between coding and runtime they are quite different to their opposite number: actions. Actions use the standard NSControl methods setTarget: and setAction: (remember Interface Builder is working with actual objects, not representations of them). Connections on the other hand and linking actual objects to a proxy object (your controller). When the NIB is loaded at runtime, this proxy object is replaced with the instance of your controller objects and then the instance variables are hooked up to the actual objects, either via accessor methods if they exist, or directly accessing the variable if they don&#8217;t.</p>
<p>3. id is not equivalent to Object. NSObject is equivalent to Object. Saying something is Object or a subclass means that Object has to be one of the superclasses. This is the same with NSObject, but id allows objects that aren&#8217;t subclasses of NSObject. In a nutshell, id is dynamic typing, NSObject is static typing. This often helps with compiler warnings. For example:</p>
<p>NSObject *myArray = [NSArray array];<br />
[myArray count];</p>
<p>Would give a warning that NSObject may not respond to the method count, even though NSArray is a subclass of NSObject. However:</p>
<p>id myArray = [NSArray array];<br />
[myArray count];</p>
<p>Would give no warning. The compiler just cares that some object somewhere responds to count and trusts the object to handle the message if it doesn&#8217;t (either by discarding it or forwarding it to another object). It also helps get rid of generics or the need for casting (you&#8217;ll notice that all collection classes in cocoa use id rather than NSObject).</p>
<p>4. Obviously this doesn&#8217;t help on the iPhone, but if you were to ever program for the Mac there is a class in Foundation called NSSound which would simplify your sound code to:</p>
<p>[[NSSound soundNamed:@"filename"] play];</p>
<p>Unfortunately this is one of the many classes that is missing from the iPhone.</p>
<p>Anyway hope this helps</p>
]]></content:encoded>
	</item>
</channel>
</rss>

