<?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>“我”的开发笔记 &#187; 08 &#8211; 列表视图（TableViews）</title>
	<atom:link href="http://c.gzl.name/archives/category/iphone/tableview/feed" rel="self" type="application/rss+xml" />
	<link>http://c.gzl.name</link>
	<description>IPhone, Cocoa, PHP, Javascript, JQuery, Actionscript, etc...</description>
	<lastBuildDate>Thu, 29 Dec 2011 07:20:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>iPhone上的JSON（三）JSON+UITableView</title>
		<link>http://c.gzl.name/archives/318</link>
		<comments>http://c.gzl.name/archives/318#comments</comments>
		<pubDate>Mon, 10 Aug 2009 22:12:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[06 - 视图控制器（ViewControllers）]]></category>
		<category><![CDATA[08 - 列表视图（TableViews）]]></category>
		<category><![CDATA[09 - 数据（Data）]]></category>
		<category><![CDATA[iPhone开发]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[UITableView]]></category>
		<category><![CDATA[UITableViewController]]></category>

		<guid isPermaLink="false">http://c.gzl.name/?p=318</guid>
		<description><![CDATA[既然JSON这么好，它怎么和UITableView结合使用呢？ 首先看看我们的JSON文件吧： { &#34;老张家&#34;:[&#34;大张&#34;,&#34;二张&#34;,&#34;三张&#34;], &#34;老李家&#34;:[&#34;大李&#34;,&#34;二李&#34;] } 完成的作品是这样样子的～～(点击放大阿～～) 好，开始打代码吧。 1，首先copy JSON库到当前的Project里面。 2，建立一个数据源类。我给它起名叫MyDataSource, 看看里面都有什么吧： @interface MyDataSource : NSObject &#123;&#125; + &#40;id&#41;dataSource; @end &#160; #import &#34;JSON.h&#34; &#160; @implementation MyDataSource + &#40;id&#41;dataSource &#123; NSString* JSONString = &#91;NSString stringWithContentsOfFile:&#91;&#91;NSBundle mainBundle&#93; pathForResource:@&#34;data&#34; ofType:@&#34;json&#34;&#93; encoding:NSUTF8StringEncoding error:nil&#93;; return &#91;JSONString JSONValue&#93;; &#125; @end 里面非常简单，只有一个类方法dataSource。在其中我们读取json文件的内容到一个NSString中，并用JSON框架来解读成一个NSDictionary，返回值为id。因为虽然大多的时候最外的对象都为NSDictionary，但是出于严谨，万一是NSArray不就崩溃了。所以使用id，这样其实就有再次可以用的特性了。 3，建立一个UITableViewController, 然后作适当的设置： #import &#34;MyTableViewController.h&#34; #import &#34;MyDataSource.h&#34; &#160; @implementation MyTableViewController &#160; [...]]]></description>
		<wfw:commentRss>http://c.gzl.name/archives/318/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>UITableViewController重要配置方法和Delegate</title>
		<link>http://c.gzl.name/archives/234</link>
		<comments>http://c.gzl.name/archives/234#comments</comments>
		<pubDate>Sat, 01 Aug 2009 21:04:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[08 - 列表视图（TableViews）]]></category>
		<category><![CDATA[iPhone开发]]></category>
		<category><![CDATA[iPhone列表方法]]></category>
		<category><![CDATA[UITableViewController]]></category>

		<guid isPermaLink="false">http://c.gzl.name/?p=234</guid>
		<description><![CDATA[UITableViewController 列表在iPhone开发中起着决定性的重要作用，但是UITableViewController并不是那么简单使用的，以下就是其中的重要方法和Delegate： //这个delegate会获取有多少个&#34;章节&#34; - &#40;NSInteger&#41;numberOfSectionsInTableView:&#40;UITableView *&#41;tableView &#123; return 1; //这里返回的是章节（section）的个数 //如果数据源是一个复杂array或dictionary，则可以返回 return &#91;NSArray count&#93;; 作为章节的个数 &#125; &#160; &#160; //这个delegate会获取章节内有多少行 - &#40;NSInteger&#41;tableView:&#40;UITableView *&#41;tableView numberOfRowsInSection:&#40;NSInteger&#41;section &#123; return 0; //这个部分是必须要改的，否则0行的话，就是一个空表了 //如果数据源是一个复杂array或dictionary, 可以使用嵌套的查询来返回这个个数了 //比如： return &#91;&#91;NSArray objectAtIndex:section&#93; //section为整数，所以如果使用NSDictionary， //记得使用辅助方法来计算其索引的key，或嵌套查询 count&#93;; //因为返回的依旧是一个array或dictionary对象，所以我们获取它的大小count &#125; &#160; &#160; &#160; // 这里编辑每个栏格的外观 - &#40;UITableViewCell *&#41;tableView:&#40;UITableView *&#41;tableView cellForRowAtIndexPath:&#40;NSIndexPath *&#41;indexPath &#123; &#160; static NSString *CellIdentifier = [...]]]></description>
		<wfw:commentRss>http://c.gzl.name/archives/234/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

