<?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>iPhoneGeek 爱疯极客 &#187; 基础</title>
	<atom:link href="http://www.iphone-geek.cn/category/%e7%bc%96%e7%a8%8b/%e5%9f%ba%e7%a1%80/feed" rel="self" type="application/rss+xml" />
	<link>http://www.iphone-geek.cn</link>
	<description>iPhone 新闻，编程，技巧与提示，代码，教程</description>
	<lastBuildDate>Thu, 08 Dec 2011 01:18:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>无法正确加载@2x的解决办法</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%97%a0%e6%b3%95%e6%ad%a3%e7%a1%ae%e5%8a%a0%e8%bd%bd2x%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%97%a0%e6%b3%95%e6%ad%a3%e7%a1%ae%e5%8a%a0%e8%bd%bd2x%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95#comments</comments>
		<pubDate>Tue, 19 Jul 2011 06:45:01 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[图形图像]]></category>
		<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[UIImage]]></category>
		<category><![CDATA[代码片段]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1177</guid>
		<description><![CDATA[为使用retina显示，我们一般把图片的高分辨率版本存为@2x的形式，但是iOS 4.1以前的版本，如果使用imageWithContentsOfFile是无法保证@2x文件正确加载的。我使用如下方法解决此问题：
123456789101112131415161718192021222324252627// UIImage+Extras.h
@interface UIImage &#40;Extras&#41;

- &#40;id&#41;initWithContentsOfResolutionIndependentFile:&#40;NSString *&#41;path;
+ &#40;UIImage*&#41;imageWithContentsOfResolutionIndependentFile:&#40;NSString *&#41;path;

@end

// UIImage+Extras.m
- &#40;id&#41;initWithContentsOfResolutionIndependentFile:&#40;NSString *&#41;path &#123;
&#160; &#160; if &#40; &#91;&#91;&#91;UIDevice currentDevice&#93; systemVersion&#93; intValue&#93; &#62;= 4 &#38;&#38; &#91;&#91;UIScreen mainScreen&#93; scale&#93; == 2.0 &#41; &#123;
&#160; &#160; &#160; &#160; NSString *path2x = &#91;&#91;path stringByDeletingLastPathComponent&#93; 
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; stringByAppendingPathComponent:&#91;NSString stringWithFormat:@&#34;%@@2x.%@&#34;, 
&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>为使用retina显示，我们一般把图片的高分辨率版本存为@2x的形式，但是iOS 4.1以前的版本，如果使用imageWithContentsOfFile是无法保证@2x文件正确加载的。我使用如下方法解决此问题：</p>
<div class="codecolorer-container objc mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><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 /></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;">// UIImage+Extras.h</span><br />
<span style="color: #a61390;">@interface</span> UIImage <span style="color: #002200;">&#40;</span>Extras<span style="color: #002200;">&#41;</span><br />
<br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithContentsOfResolutionIndependentFile<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path;<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>UIImage<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>imageWithContentsOfResolutionIndependentFile<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path;<br />
<br />
<span style="color: #a61390;">@end</span><br />
<br />
<span style="color: #11740a; font-style: italic;">// UIImage+Extras.m</span><br />
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithContentsOfResolutionIndependentFile<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIDevice currentDevice<span style="color: #002200;">&#93;</span> systemVersion<span style="color: #002200;">&#93;</span> intValue<span style="color: #002200;">&#93;</span> &gt;<span style="color: #002200;">=</span> 4 <span style="color: #002200;">&amp;&amp;</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIScreen mainScreen<span style="color: #002200;">&#93;</span> scale<span style="color: #002200;">&#93;</span> <span style="color: #002200;">==</span> 2.0 <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span>path2x <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>path stringByDeletingLastPathComponent<span style="color: #002200;">&#93;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@@2x.%@&quot;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>path lastPathComponent<span style="color: #002200;">&#93;</span> stringByDeletingPathExtension<span style="color: #002200;">&#93;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>path pathExtension<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/"><span style="color: #400080;">NSFileManager</span></a> defaultManager<span style="color: #002200;">&#93;</span> fileExistsAtPath<span style="color: #002200;">:</span>path2x<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>self initWithCGImage<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImage imageWithData<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/"><span style="color: #400080;">NSData</span></a> dataWithContentsOfFile<span style="color: #002200;">:</span>path2x<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span> CGImage<span style="color: #002200;">&#93;</span> scale<span style="color: #002200;">:</span>2.0 orientation<span style="color: #002200;">:</span>UIImageOrientationUp<span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>self initWithData<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/"><span style="color: #400080;">NSData</span></a> dataWithContentsOfFile<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>UIImage<span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>imageWithContentsOfResolutionIndependentFile<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIImage alloc<span style="color: #002200;">&#93;</span> initWithContentsOfResolutionIndependentFile<span style="color: #002200;">:</span>path<span style="color: #002200;">&#93;</span> autorelease<span style="color: #002200;">&#93;</span>;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%97%a0%e6%b3%95%e6%ad%a3%e7%a1%ae%e5%8a%a0%e8%bd%bd2x%e7%9a%84%e8%a7%a3%e5%86%b3%e5%8a%9e%e6%b3%95/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>不需重新编译而更改app资源内容的简单方法</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e4%b8%8d%e9%9c%80%e9%87%8d%e6%96%b0%e7%bc%96%e8%af%91%e8%80%8c%e6%9b%b4%e6%94%b9app%e8%b5%84%e6%ba%90%e5%86%85%e5%ae%b9%e7%9a%84%e7%ae%80%e5%8d%95%e6%96%b9%e6%b3%95</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e4%b8%8d%e9%9c%80%e9%87%8d%e6%96%b0%e7%bc%96%e8%af%91%e8%80%8c%e6%9b%b4%e6%94%b9app%e8%b5%84%e6%ba%90%e5%86%85%e5%ae%b9%e7%9a%84%e7%ae%80%e5%8d%95%e6%96%b9%e6%b3%95#comments</comments>
		<pubDate>Tue, 24 May 2011 02:36:22 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[提示与技巧]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1173</guid>
		<description><![CDATA[有的时候，我们需要把做好的项目以另外的程序名和内容重新打包，当然我们可以使用建立一个新的target的方法，不同的情况用不同的target表示。我一位朋友luckywr分享了一种更为简单的方法，特别适合于只需少量更改了项目的内容（比如，更改程序的图标）。其思路也非常简单，就是在更改内容后使用命令行对app重新进行数字签名，而不需要再次对整个程序进行编译了。
下面是他使用的方法：

codesign -f -vv -s [Identity] [appPath]
Identity 是授权文件，是在keychain里使用的私钥的名字。
比如：codesign -f -vv -s &#8220;luckywr&#8221; /Users/luckywr/Desktop/xxxx.app

在此感谢luckywr朋友。
]]></description>
			<content:encoded><![CDATA[<p>有的时候，我们需要把做好的项目以另外的程序名和内容重新打包，当然我们可以使用建立一个新的target的方法，不同的情况用不同的target表示。我一位朋友<a href="luckywr@gmail.com">luckywr</a>分享了一种更为简单的方法，特别适合于只需少量更改了项目的内容（比如，更改程序的图标）。其思路也非常简单，就是在更改内容后使用命令行对app重新进行数字签名，而不需要再次对整个程序进行编译了。</p>
<p>下面是他使用的方法：</p>
<blockquote>
<p>codesign -f -vv -s [Identity] [appPath]</p>
<p>Identity 是授权文件，是在keychain里使用的私钥的名字。</p>
<p>比如：codesign -f -vv -s &#8220;luckywr&#8221; /Users/luckywr/Desktop/xxxx.app</p>
</blockquote>
<p>在此感谢luckywr朋友。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e4%b8%8d%e9%9c%80%e9%87%8d%e6%96%b0%e7%bc%96%e8%af%91%e8%80%8c%e6%9b%b4%e6%94%b9app%e8%b5%84%e6%ba%90%e5%86%85%e5%ae%b9%e7%9a%84%e7%ae%80%e5%8d%95%e6%96%b9%e6%b3%95/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xcode 4闲谈</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/xcode-4</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/xcode-4#comments</comments>
		<pubDate>Thu, 31 Mar 2011 04:47:02 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1150</guid>
		<description><![CDATA[Xcode 4终于千呼万唤发布了，诚然它有太多亮点，不过目前还是感觉不够稳定，还有很多功能都不会用。举个简单的例子，在Ｘcode 3下，使用Analyze时有非常多的误报，但Ｘcode 4似乎又走了另一个极端，几乎没有什么报告。我有一个程序明显有memory leak（因为我安装了状态条可以显示内存的软件），但Analyze的结果是没有potential leak，而且使用Instrument也没有发现任何leak，不知是不是我还不太会用。
另外，还有一些以前比较熟练的事情在Xcode 4下，都不会做了。比如， 当程序出现EXC_BAD_ACCESS时添加NSZombieEnabled环境变量开始都找不到地方。最后终于找到了，在：
Product -&#62; Edit Scheme&#8230;

4月1日更新：
今天发现一个有趣的现象。突然发现以前为Xcode项目添加静态库子项目的方法不再适用，添加的项目文件只是一个文件而已。后来经过研究才发现是因为Xcode打开了另外一个项目的缘故。关掉另一个Xcode后，问题解决。
]]></description>
			<content:encoded><![CDATA[<p>Xcode 4终于千呼万唤发布了，诚然它有太多亮点，不过目前还是感觉不够稳定，还有很多功能都不会用。举个简单的例子，在Ｘcode 3下，使用Analyze时有非常多的误报，但Ｘcode 4似乎又走了另一个极端，几乎没有什么报告。我有一个程序明显有memory leak（因为我安装了状态条可以显示内存的软件），但Analyze的结果是没有potential leak，而且使用Instrument也没有发现任何leak，不知是不是我还不太会用。<br class="spacer_" /><br />
另外，还有一些以前比较熟练的事情在Xcode 4下，都不会做了。比如， 当程序出现EXC_BAD_ACCESS时添加NSZombieEnabled环境变量开始都找不到地方。最后终于找到了，在：</p>
<blockquote><p>Product -&gt; Edit Scheme&#8230;</p></blockquote>
<p><br class="spacer_" /><br />
<strong>4月1日更新：</strong><br />
今天发现一个有趣的现象。突然发现以前为Xcode项目添加静态库子项目的方法不再适用，添加的项目文件只是一个文件而已。后来经过研究才发现是因为Xcode打开了另外一个项目的缘故。关掉另一个Xcode后，问题解决。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/xcode-4/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>怎样关闭后台运行</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%80%8e%e6%a0%b7%e5%85%b3%e9%97%ad%e5%90%8e%e5%8f%b0%e8%bf%90%e8%a1%8c</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%80%8e%e6%a0%b7%e5%85%b3%e9%97%ad%e5%90%8e%e5%8f%b0%e8%bf%90%e8%a1%8c#comments</comments>
		<pubDate>Fri, 25 Mar 2011 00:15:47 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[后台程序]]></category>
		<category><![CDATA[提示与技巧]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1148</guid>
		<description><![CDATA[iOS 4引进了所谓多任务，可以让程序运行于后台，不过对目前大部分程序而言这只是一个鸡肋。有没有办法直接在用户按下Home键后像iOS 4之前的程序一样直接退出呢？方法如下：

打开info.plist
加入 UIApplicationExitsOnSuspend 或者选择“Application does not run in background（程序不运行于后台）”
将其设为 YES

]]></description>
			<content:encoded><![CDATA[<p>iOS 4引进了所谓多任务，可以让程序运行于后台，不过对目前大部分程序而言这只是一个鸡肋。有没有办法直接在用户按下Home键后像iOS 4之前的程序一样直接退出呢？方法如下：</p>
<ol>
<li>打开info.plist</li>
<li>加入 <strong>UIApplicationExitsOnSuspend</strong> 或者选择“Application does not run in background（程序不运行于后台）”</li>
<li>将其设为 YES</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%80%8e%e6%a0%b7%e5%85%b3%e9%97%ad%e5%90%8e%e5%8f%b0%e8%bf%90%e8%a1%8c/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSOperation和NSURLConnection</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/nsoperation%e5%92%8cnsurlconnection</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/nsoperation%e5%92%8cnsurlconnection#comments</comments>
		<pubDate>Wed, 23 Feb 2011 05:48:27 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[线程]]></category>
		<category><![CDATA[提示与技巧]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1128</guid>
		<description><![CDATA[最近一个客户向我汇报了一个程序的问题。经过分析发现问题是NSURLConnection没有正常工作。记得以前测试时没有问题啊。后来上网查到原来在iOS 4.0以后，NSURLConnection无法在NSOperation中正常运行，换句话说，NSURLConnection只能运行于主线程。解决方法其实倒是蛮简单（比如我的程序在download中）：
123456789101112-&#40;void&#41;download
&#123;
&#160; &#160; // NSURLConnectionn won't work if it's not in the main thread
&#160; &#160; if &#40;!&#91;NSThread isMainThread&#93;&#41;
&#160; &#160; &#123;
&#160; &#160; &#160; &#160; &#91;self performSelectorOnMainThread:@selector&#40;download&#41; withObject:nil waitUntilDone:NO&#93;;
&#160; &#160; &#160; &#160; return;
&#160; &#160; &#125;
&#160; &#160; 
&#160; &#160; NSURLRequest *request = &#91;NSURLRequest requestWithURL:&#91;NSURL URLWithString:_urlString&#93;&#93;;
&#160; &#160; _connection = &#91;&#91;NSURLConnection alloc&#93; initWithRequest:request delegate:self&#93;;&#160; &#160; &#160; 
&#125;
]]></description>
			<content:encoded><![CDATA[<p>最近一个客户向我汇报了一个程序的问题。经过分析发现问题是NSURLConnection没有正常工作。记得以前测试时没有问题啊。后来上网查到原来在iOS 4.0以后，NSURLConnection无法在NSOperation中正常运行，换句话说，NSURLConnection只能运行于主线程。解决方法其实倒是蛮简单（比如我的程序在download中）：</p>
<div class="codecolorer-container objc mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><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 /></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;">void</span><span style="color: #002200;">&#41;</span>download<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #11740a; font-style: italic;">// NSURLConnectionn won't work if it's not in the main thread</span><br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSThread_Class/"><span style="color: #400080;">NSThread</span></a> isMainThread<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>self performSelectorOnMainThread<span style="color: #002200;">:</span><span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>download<span style="color: #002200;">&#41;</span> withObject<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span> waitUntilDone<span style="color: #002200;">:</span><span style="color: #a61390;">NO</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/"><span style="color: #400080;">NSURLRequest</span></a> <span style="color: #002200;">*</span>request <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLRequest_Class/"><span style="color: #400080;">NSURLRequest</span></a> requestWithURL<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/"><span style="color: #400080;">NSURL</span></a> URLWithString<span style="color: #002200;">:</span>_urlString<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; _connection <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/"><span style="color: #400080;">NSURLConnection</span></a> alloc<span style="color: #002200;">&#93;</span> initWithRequest<span style="color: #002200;">:</span>request delegate<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;&nbsp; &nbsp; &nbsp; <br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/nsoperation%e5%92%8cnsurlconnection/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>检测当前设备是否为iPad</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%a3%80%e6%b5%8b%e5%bd%93%e5%89%8d%e8%ae%be%e5%a4%87%e6%98%af%e5%90%a6%e4%b8%baipad</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%a3%80%e6%b5%8b%e5%bd%93%e5%89%8d%e8%ae%be%e5%a4%87%e6%98%af%e5%90%a6%e4%b8%baipad#comments</comments>
		<pubDate>Fri, 07 Jan 2011 06:42:13 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[代码片段]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1100</guid>
		<description><![CDATA[今天编写一个程序时需要检测当前设备是否为iPad，正好用到开源Cocos2d库，发现里面是使用下面代码段进行检测的：
&#160;

12345&#160; &#160; if &#40;UI_USER_INTERFACE_IDIOM&#40;&#41; == UIUserInterfaceIdiomPad&#41; &#123;
&#160; &#160; &#160; &#160; &#91;_pages addObject:@&#34;page1-ipad.jpg&#34;&#93;;
&#160; &#160; &#125; else &#123;
&#160; &#160; &#160; &#160; &#91;_pages addObject:@&#34;page2.jpg&#34;&#93;;
&#160; &#160; &#125;

&#038;nbsp
]]></description>
			<content:encoded><![CDATA[<p>今天编写一个程序时需要检测当前设备是否为iPad，正好用到开源Cocos2d库，发现里面是使用下面代码段进行检测的：</p>
<p>&nbsp;</p>
<blockquote>
<div class="codecolorer-container objc mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><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 /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>UI_USER_INTERFACE_IDIOM<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">==</span> UIUserInterfaceIdiomPad<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_pages addObject<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;page1-ipad.jpg&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #002200;">&#91;</span>_pages addObject<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;page2.jpg&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
</blockquote>
<p>&#038;nbsp</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%a3%80%e6%b5%8b%e5%bd%93%e5%89%8d%e8%ae%be%e5%a4%87%e6%98%af%e5%90%a6%e4%b8%baipad/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>程序中读取可用内存</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e7%a8%8b%e5%ba%8f%e4%b8%ad%e8%af%bb%e5%8f%96%e5%8f%af%e7%94%a8%e5%86%85%e5%ad%98</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e7%a8%8b%e5%ba%8f%e4%b8%ad%e8%af%bb%e5%8f%96%e5%8f%af%e7%94%a8%e5%86%85%e5%ad%98#comments</comments>
		<pubDate>Tue, 23 Nov 2010 08:33:27 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[内存管理]]></category>
		<category><![CDATA[代码片段]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1092</guid>
		<description><![CDATA[iPhone/iPad的内存十分紧张，所以有时进行调试时可能需要读取当前可用内存。其实挺简单，见下列代码：
1234567891011121314151617181920#import &#60;mach/mach.h&#62;
#import &#60;mach/mach_host.h&#62;

@implementation Utils

+ &#40;double&#41;getAvailableMemory
&#123;
&#160; &#160; vm_statistics_data_t vmStats;
&#160; &#160; mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
&#160; &#160; kern_return_t kernReturn = host_statistics&#40;mach_host_self&#40;&#41;, HOST_VM_INFO, &#40;host_info_t&#41;&#38;vmStats, &#38;infoCount&#41;;
&#160; &#160; 
&#160; &#160; if &#40;kernReturn != KERN_SUCCESS&#41;
&#160; &#160; &#123;
&#160; &#160; &#160; &#160; return NSNotFound;
&#160; &#160; &#125;
&#160; &#160; 
&#160; &#160; return &#40;vm_page_size * vmStats.free_count&#41;;
&#125;

end
使用方法更简单，比如：
1NSLog&#40;@&#34;Available memory (KB) = &#160;%f&#34;,&#91;Utils getAvailableMemory&#93;&#41;;
]]></description>
			<content:encoded><![CDATA[<p>iPhone/iPad的内存十分紧张，所以有时进行调试时可能需要读取当前可用内存。其实挺简单，见下列代码：</p>
<div class="codecolorer-container objc mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><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 /></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: #6e371a;">#import &lt;mach/mach.h&gt;</span><br />
<span style="color: #6e371a;">#import &lt;mach/mach_host.h&gt;</span><br />
<br />
<span style="color: #a61390;">@implementation</span> Utils<br />
<br />
<span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">double</span><span style="color: #002200;">&#41;</span>getAvailableMemory<br />
<span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; vm_statistics_data_t vmStats;<br />
&nbsp; &nbsp; mach_msg_type_number_t infoCount <span style="color: #002200;">=</span> HOST_VM_INFO_COUNT;<br />
&nbsp; &nbsp; kern_return_t kernReturn <span style="color: #002200;">=</span> host_statistics<span style="color: #002200;">&#40;</span>mach_host_self<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>, HOST_VM_INFO, <span style="color: #002200;">&#40;</span>host_info_t<span style="color: #002200;">&#41;</span><span style="color: #002200;">&amp;</span>vmStats, <span style="color: #002200;">&amp;</span>infoCount<span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>kernReturn <span style="color: #002200;">!=</span> KERN_SUCCESS<span style="color: #002200;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #a61390;">return</span> NSNotFound;<br />
&nbsp; &nbsp; <span style="color: #002200;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> <span style="color: #002200;">&#40;</span>vm_page_size <span style="color: #002200;">*</span> vmStats.free_count<span style="color: #002200;">&#41;</span>;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
end</div></td></tr></tbody></table></div>
<p>使用方法更简单，比如：</p>
<div class="codecolorer-container objc mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><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">NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Available memory (KB) = &nbsp;%f&quot;</span>,<span style="color: #002200;">&#91;</span>Utils getAvailableMemory<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e7%a8%8b%e5%ba%8f%e4%b8%ad%e8%af%bb%e5%8f%96%e5%8f%af%e7%94%a8%e5%86%85%e5%ad%98/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xcode不支持iPhoe OS 3.2.1的解决方法</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/xcode%e4%b8%8d%e6%94%af%e6%8c%81iphoe-os-3-2-1%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/xcode%e4%b8%8d%e6%94%af%e6%8c%81iphoe-os-3-2-1%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95#comments</comments>
		<pubDate>Wed, 01 Sep 2010 06:15:10 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[系统安装]]></category>
		<category><![CDATA[调试]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[提示与技巧]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1069</guid>
		<description><![CDATA[最近iPad升级到iPhone 3.2.1，今天准备进行真机调试，猛然发现Xcode下出现下列错误：

The version of iPhone OS on &#8220;xxxx&#8221; does not match any of the versions of iPhone OS supported for development with this copy of Xcode. Please restore the device to a version of the OS listed below. If necessary, the latest version of Xcode is available here.

Google 了一下，发现是3.2.1的目录在DeviceSupport下不存在。解决办法是用最接近的OS版本使用ln命令进行链接。不过在操作过程中有两个问题：

1. 不知什么原因，ln -s 命令后总是为文件而不是目录
2. 不知OS 3.2的build number

于是，采用最笨但最为有效的方法：

在/Developer/Platforms/iPhoneOS.platform/DeviceSupport目录下创建3.2.1目录，然后，将3.2下所有文件及目录复制到3.2.1下，重新启动Xcode，问题解决。
]]></description>
			<content:encoded><![CDATA[<p>最近iPad升级到iPhone 3.2.1，今天准备进行真机调试，猛然发现Xcode下出现下列错误：<br />
<br class="spacer_" /><br />
The version of iPhone OS on &#8220;xxxx&#8221; does not match any of the versions of iPhone OS supported for development with this copy of Xcode. Please restore the device to a version of the OS listed below. If necessary, the latest version of Xcode is available here.<br />
<br class="spacer_" /><br />
Google 了一下，发现是3.2.1的目录在DeviceSupport下不存在。解决办法是用最接近的OS版本使用ln命令进行链接。不过在操作过程中有两个问题：<br />
<br class="spacer_" /><br />
1. 不知什么原因，ln -s 命令后总是为文件而不是目录<br />
2. 不知OS 3.2的build number<br />
<br class="spacer_" /><br />
于是，采用最笨但最为有效的方法：<br />
<br class="spacer_" /><br />
在/Developer/Platforms/iPhoneOS.platform/DeviceSupport目录下创建3.2.1目录，然后，将3.2下所有文件及目录复制到3.2.1下，重新启动Xcode，问题解决。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/xcode%e4%b8%8d%e6%94%af%e6%8c%81iphoe-os-3-2-1%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>修改公司名称的“新”方法</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e4%bf%ae%e6%94%b9%e5%85%ac%e5%8f%b8%e5%90%8d%e7%a7%b0%e7%9a%84%e2%80%9c%e6%96%b0%e2%80%9d%e6%96%b9%e6%b3%95</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e4%bf%ae%e6%94%b9%e5%85%ac%e5%8f%b8%e5%90%8d%e7%a7%b0%e7%9a%84%e2%80%9c%e6%96%b0%e2%80%9d%e6%96%b9%e6%b3%95#comments</comments>
		<pubDate>Fri, 20 Aug 2010 04:52:41 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1064</guid>
		<description><![CDATA[以前发过一篇文章介绍怎样修改Xcode中的公司名称，见怎样替换Xcode中__MyCompanyName__。
现在（不知是从Xcode哪个版本开始，我是3.2.3）可以有更简单的方法修改公司名称，而且还可以在基于项目修改。方法如下：
1. 右击项目名称，选择“Get Info&#8230;”
2. 在“General Settings”一栏中可以看到“Organization Name”，修改它，那么本项目中的公司名称就修改了。
]]></description>
			<content:encoded><![CDATA[<p>以前发过一篇文章介绍怎样修改Xcode中的公司名称，见<a href="技巧与提示/怎样替换xcode中__mycompanyname__">怎样替换Xcode中__MyCompanyName__</a>。</p>
<p>现在（不知是从Xcode哪个版本开始，我是3.2.3）可以有更简单的方法修改公司名称，而且还可以在基于项目修改。方法如下：</p>
<p>1. 右击项目名称，选择“Get Info&#8230;”<br />
2. 在“General Settings”一栏中可以看到“Organization Name”，修改它，那么本项目中的公司名称就修改了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e4%bf%ae%e6%94%b9%e5%85%ac%e5%8f%b8%e5%90%8d%e7%a7%b0%e7%9a%84%e2%80%9c%e6%96%b0%e2%80%9d%e6%96%b9%e6%b3%95/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>怎样离线使用iPhone SDK文档</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%80%8e%e6%a0%b7%e7%a6%bb%e7%ba%bf%e4%bd%bf%e7%94%a8iphone-sdk%e6%96%87%e6%a1%a3</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%80%8e%e6%a0%b7%e7%a6%bb%e7%ba%bf%e4%bd%bf%e7%94%a8iphone-sdk%e6%96%87%e6%a1%a3#comments</comments>
		<pubDate>Wed, 18 Aug 2010 06:34:38 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[提示与技巧]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=1055</guid>
		<description><![CDATA[我是用Dell机安装的雪豹系统，由于没有无线网卡的支持，所以上网很不方便。在使用Xcode进行iPhone编程时，有时需要参考iPhone SDK的文档，不过每次Control+Click后，Xcode都会试图连接Internet，进行在线读取。有什么方法能够把资料下载到硬盘上进行离线阅读吗？

答案是肯定的。首先去Xcode的Preference中的Documentation Sets下，选择所需的docset，这里是iPhone 4.0 Reference Library，右击选择“Get Info&#8230;”，找到Feed URL：

http://developer.apple.com/rss/com.apple.adc.documentation.AppleiPhone4_0.atom

用浏览器打开，下面列出了许多版本，在Windows下你就可以使用迅雷下载了。

下载后，拷贝到Mac的/Developer/Documentations/Docset目录下，使用终端命令：


sudo xar -xf 下载的文件名.xar


将其解压，然后使用:


sudo chown -R -P devdocs 解压后的文件名.docset


将文档的所有者改为devdocs。打开Xcode就可以离线浏览了。
]]></description>
			<content:encoded><![CDATA[<p>我是用Dell机安装的雪豹系统，由于没有无线网卡的支持，所以上网很不方便。在使用Xcode进行iPhone编程时，有时需要参考iPhone SDK的文档，不过每次Control+Click后，Xcode都会试图连接Internet，进行在线读取。有什么方法能够把资料下载到硬盘上进行离线阅读吗？<br />
<br class="spacer_" /><br />
答案是肯定的。首先去Xcode的Preference中的Documentation Sets下，选择所需的docset，这里是iPhone 4.0 Reference Library，右击选择“Get Info&#8230;”，找到Feed URL：<br />
<br class="spacer_" /><br />
<a "http://developer.apple.com/rss/com.apple.adc.documentation.AppleiPhone4_0.atom">http://developer.apple.com/rss/com.apple.adc.documentation.AppleiPhone4_0.atom</a><br />
<br class="spacer_" /><br />
用浏览器打开，下面列出了许多版本，在Windows下你就可以使用迅雷下载了。<br />
<br class="spacer_" /><br />
下载后，拷贝到Mac的/Developer/Documentations/Docset目录下，使用终端命令：<br />
<br class="spacer_" /></p>
<blockquote><p>
sudo xar -xf 下载的文件名.xar
</p></blockquote>
<p><br class="spacer_" /><br />
将其解压，然后使用:<br />
<br class="spacer_" /></p>
<blockquote><p>
sudo chown -R -P devdocs 解压后的文件名.docset
</p></blockquote>
<p><br class="spacer_" /><br />
将文档的所有者改为devdocs。打开Xcode就可以离线浏览了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e6%80%8e%e6%a0%b7%e7%a6%bb%e7%ba%bf%e4%bd%bf%e7%94%a8iphone-sdk%e6%96%87%e6%a1%a3/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

