<?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>ODM Technology &#187; objective c</title>
	<atom:link href="http://blog.odmtech.com/tag/objective-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.odmtech.com</link>
	<description>Ord's Blog</description>
	<lastBuildDate>Sat, 04 Jul 2009 15:22:00 +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 tableView</title>
		<link>http://blog.odmtech.com/2009/03/02/iphone-tableview/</link>
		<comments>http://blog.odmtech.com/2009/03/02/iphone-tableview/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 17:52:27 +0000</pubDate>
		<dc:creator>Ord</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[tableView]]></category>

		<guid isPermaLink="false">http://blog.odmtech.com/?p=45</guid>
		<description><![CDATA[The Table View is widely used in iPhone apps, and ther are many examples of using it on navigation pages in the iPhone SDK example programs.  These examples generally show how to add a tableView that fills the screen, or sometimes with a Navigation  Bar element at the top.
Sometimes, we want to use a table [...]]]></description>
			<content:encoded><![CDATA[<p>The Table View is widely used in iPhone apps, and ther are many examples of using it on navigation pages in the iPhone SDK example programs.  These examples generally show how to add a tableView that fills the screen, or sometimes with a Navigation  Bar element at the top.</p>
<p>Sometimes, we want to use a table view as a smaller element within another view.  The iPhone Clock app uses this approache in stopwatch mode to show the lap times.</p>
<p>In this case, the view that contains the TableView will typically be a subclass of UIViewController.  We need only add the protocols UITableViewDelegate and UITableViewDataSource to our view.  This is done in the header file:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#import &lt;UIKit/UIKit.h&gt;</span>
&nbsp;
@interface MyViewController <span style="color: #339933;">:</span> UIViewController 
  <span style="color: #339933;">&lt;</span>UITableViewDelegate<span style="color: #339933;">,</span> UITableViewDataSource<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span>
@end</pre></div></div>

<p>For a simple view, we will need to add the numberOfRowsInSection and cellForRowAtIndex methods.  This example shows a table of 5 rows, with cells labeled Item #0 to Item #4.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#import &quot;MyViewController.h&quot;</span>
&nbsp;
@implementation MyViewController
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>NSInteger<span style="color: #009900;">&#41;</span>tableView<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>UITableView <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>tableView
  numberOfRowsInSection<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSInteger<span style="color: #009900;">&#41;</span>section<span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">5</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// we want 5 rows in our table.</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>UITableViewCell <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>tableView<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>UITableView <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>tableView
     cellForRowAtIndexPath<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span>NSIndexPath <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>indexPath<span style="color: #009900;">&#123;</span>
&nbsp;
     NSString <span style="color: #339933;">*</span>Identifier <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#91;</span>NSString alloc<span style="color: #009900;">&#93;</span> initWithFormat<span style="color: #339933;">:</span>@<span style="color: #ff0000;">&quot;Item #%d&quot;</span><span style="color: #339933;">,</span> 
          <span style="color: #009900;">&#91;</span>indexPath indexAtPosition<span style="color: #339933;">:</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
     UITableViewCell <span style="color: #339933;">*</span>cell <span style="color: #339933;">=</span>
          <span style="color: #009900;">&#91;</span>tableView dequeueReusableCellWithIdentifier<span style="color: #339933;">:</span>Identifier<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>cell <span style="color: #339933;">==</span> nil<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          cell <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#91;</span>UITableViewCell alloc<span style="color: #009900;">&#93;</span> 
               initWithFrame<span style="color: #339933;">:</span>CGRectZero reuseIdentifier<span style="color: #339933;">:</span> Identifier<span style="color: #009900;">&#93;</span> 
               autorelease<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
     cell.<span style="color: #202020;">text</span> <span style="color: #339933;">=</span> Identifier<span style="color: #339933;">;</span>	
     <span style="color: #b1b100;">return</span> cell<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
@end</pre></div></div>

<p>In interface builder, connect the datasource and delegate outlets from your table view directly to file&#8217;s owner.  There is no need to add a tableViewController to the nib.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.odmtech.com/2009/03/02/iphone-tableview/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Learning iPhone development</title>
		<link>http://blog.odmtech.com/2009/02/27/learning-iphone-development/</link>
		<comments>http://blog.odmtech.com/2009/02/27/learning-iphone-development/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 03:15:03 +0000</pubDate>
		<dc:creator>Ord</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[SDK]]></category>

		<guid isPermaLink="false">http://blog.odmtech.com/?p=43</guid>
		<description><![CDATA[Starting to develop on the iPhone is surprisingly straightforward.  Having previously developped on the palm platform, I expected the SDK to be similar in complexity and learning time.  I was happy to find that the iPhones SDK and tools are remarkably quick to learn.
It had been some time since I did any C or C++ [...]]]></description>
			<content:encoded><![CDATA[<p>Starting to develop on the iPhone is surprisingly straightforward.  Having previously developped on the palm platform, I expected the SDK to be similar in complexity and learning time.  I was happy to find that the iPhones SDK and tools are remarkably quick to learn.</p>
<p>It had been some time since I did any C or C++ coding, so I wasn&#8217;t sure how I&#8217;d like learning objective-C.   It turned out to be easy enough, once I got used to the [object message] syntax.</p>
<p>For a quick guide to getting started, take a look a <a href="http://furbo.org/2009/02/19/bootstrap/">Furbo.org &#8211; Boostrap article.</a> I ordered several of the books recommended there, including <a href="http://www.amazon.com/gp/product/1430216263?ie=UTF8&amp;tag=odmtech-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1430216263">Beginning iPhone Development: Exploring the iPhone SDK</a><img style="border:none !important; margin:0px !important;" src="http://www.assoc-amazon.com/e/ir?t=odmtech-20&amp;l=as2&amp;o=1&amp;a=1430216263" border="0" alt="" width="1" height="1" />, and I find this to be an excellent book.  Not only does it teach iPhone coding in detail,but it also covers using XCode and Interface Builder.  Since I had never used a Mac before for anything, the explanations of the development tools were very welcome.</p>
<p>Getting a developer account under for my corporation has been taking some time, but I was able to get a personal account in 30 minutes.  I finally received a request from Apple to fax them my articles of incorporation.  I am not sure how long it will take from then, and I am not sure if I will bother with the corporate account since it will make very little difference in my case.</p>
<p>It will still take a few more days to come up to speed, and then app development can start.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.odmtech.com/2009/02/27/learning-iphone-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
