<?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; Xcode</title>
	<atom:link href="http://www.iphone-geek.cn/tag/xcode/feed" rel="self" type="application/rss+xml" />
	<link>http://www.iphone-geek.cn</link>
	<description>iPhone 新闻，编程，技巧与提示，代码，教程</description>
	<lastBuildDate>Sun, 25 Jul 2010 13:49:13 +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>iPhone项目使用静态库的最佳方法</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/iphone%e9%a1%b9%e7%9b%ae%e4%bd%bf%e7%94%a8%e9%9d%99%e6%80%81%e5%ba%93%e7%9a%84%e6%9c%80%e4%bd%b3%e6%96%b9%e6%b3%95</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/iphone%e9%a1%b9%e7%9b%ae%e4%bd%bf%e7%94%a8%e9%9d%99%e6%80%81%e5%ba%93%e7%9a%84%e6%9c%80%e4%bd%b3%e6%96%b9%e6%b3%95#comments</comments>
		<pubDate>Tue, 22 Dec 2009 05:20:40 +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=369</guid>
		<description><![CDATA[由于Apple禁止在iPhone中使用外部框架或动态链接库，所以要重用代码（第三方库或自己的代码）只能选择如下方法：

直接将代码加入项目。这种方法有点笨。例如，你的一段代码被五个项目共享，如果你发现一个小bug，那么你需要更改五个地方。够麻烦吧？
使用静态库。这是我经常使用的方法。但Xcode并未为iPhone提供静态库的模板。有两种解决方法：



如果你的项目主要是使用Objective-C（C/C++也可使用，只要做些简单修改），那么你可使用现成的Xcode模板。
通过Mac OS X栏下的Static Library中的BSD Static Library建立一个静态库。但要用于iPhone项目，还需做些修改（需要将项目的Base SDK改为iPhone）。

&#160;


&#160;
但怎样在项目中链接静态库呢？如果你熟悉Xcode，那么你可跳过此段。很简单：

指定静态库的头文件路径Head Search Paths。


添加静态库到Xcode项目中。




&#160;
就这么简单。但是且慢，万事大吉了吗？如果你要修改你的静态库呢？你需要从Find中找到你的静态库项目，打开它修改。有点麻烦，不能像Visual Studio一样将相关项目包括在应用项目中吗？答案是：可以，虽然还是没有Visual Studio中的工作空间好用。但你可以从Xcode中直接打开相关的静态库。方法是使用Xcode的Cross-Project Reference(跨项目参考)。

将静态库的Xcode项目加入到当前项目。


右击Targets下本项目，添加到静态库项目的关联。


在项目下，扩展静态库项目，拖动xxxx.a到Targets下的Link Binary With Libraries。



&#160;
这样你就可以从当前项目下，双击静态库的项目来打开和修改静态库的代码了。
]]></description>
			<content:encoded><![CDATA[<p>由于Apple禁止在iPhone中使用外部框架或动态链接库，所以要重用代码（第三方库或自己的代码）只能选择如下方法：</p>
<ol>
<li>直接将代码加入项目。这种方法有点笨。例如，你的一段代码被五个项目共享，如果你发现一个小bug，那么你需要更改五个地方。够麻烦吧？</li>
<li>使用静态库。这是我经常使用的方法。但Xcode并未为iPhone提供静态库的模板。有两种解决方法：</li>
</ol>
<p><span id="more-369"></span></p>
<ul>
<li>如果你的项目主要是使用Objective-C（C/C++也可使用，只要做些简单修改），那么你可使用现成的<a href="http://www.iphone-geek.cn/%E7%BC%96%E7%A8%8B/iphone%E9%9D%99%E6%80%81%E5%BA%93%E9%A1%B9%E7%9B%AE%E6%A8%A1%E6%9D%BF">Xcode模板</a>。</li>
<li>通过Mac OS X栏下的Static Library中的BSD Static Library建立一个静态库。但要用于iPhone项目，还需做些修改（需要将项目的Base SDK改为iPhone）。</li>
</ul>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://www.iphone-geek.cn/wp-content/uploads/2009/12/1.jpg"><img class="size-full wp-image-501 aligncenter" title="1" src="http://www.iphone-geek.cn/wp-content/uploads/2009/12/1.jpg" alt="1" width="480" height="354" /></a></p>
<p style="text-align: center;"><img title="2" src="http://www.iphone-geek.cn/wp-content/uploads/2009/12/2.jpg" alt="2" width="519" height="490" /></p>
<p>&nbsp;</p>
<p>但怎样在项目中链接静态库呢？如果你熟悉Xcode，那么你可跳过此段。很简单：</p>
<ol>
<li>指定静态库的头文件路径Head Search Paths。<br />
<a href="http://www.iphone-geek.cn/wp-content/uploads/2009/12/2.jpg"></a></li>
<p style="text-align: center;"><img title="3" src="http://www.iphone-geek.cn/wp-content/uploads/2009/12/3.jpg" alt="3" width="519" height="490" /></p>
<li>添加静态库到Xcode项目中。<br />
<a href="http://www.iphone-geek.cn/wp-content/uploads/2009/12/3.jpg"></a><a href="http://www.iphone-geek.cn/wp-content/uploads/2009/12/4.jpg"></a></li>
<p style="text-align: center;"><img class="alignnone size-full wp-image-504" title="4" src="http://www.iphone-geek.cn/wp-content/uploads/2009/12/4.jpg" alt="4" width="383" height="354" /></p>
<p style="text-align: center;">
</ol>
<p>&nbsp;</p>
<p>就这么简单。但是且慢，万事大吉了吗？如果你要修改你的静态库呢？你需要从Find中找到你的静态库项目，打开它修改。有点麻烦，不能像Visual Studio一样将相关项目包括在应用项目中吗？答案是：可以，虽然还是没有Visual Studio中的工作空间好用。但你可以从Xcode中直接打开相关的静态库。方法是使用Xcode的Cross-Project Reference(跨项目参考)。</p>
<ol>
<li>将静态库的Xcode项目加入到当前项目。<br />
<a href="http://www.iphone-geek.cn/wp-content/uploads/2009/12/5.jpg"></a></li>
<p style="text-align: center;"><img class="alignnone size-full wp-image-505" title="5" src="http://www.iphone-geek.cn/wp-content/uploads/2009/12/5.jpg" alt="5" width="298" height="383" /></p>
<li>右击Targets下本项目，添加到静态库项目的关联。<br />
<a href="http://www.iphone-geek.cn/wp-content/uploads/2009/12/6.jpg"></a></li>
<p style="text-align: center;"><img class="alignnone size-full wp-image-506" title="6" src="http://www.iphone-geek.cn/wp-content/uploads/2009/12/6.jpg" alt="6" width="519" height="490" /></p>
<li>在项目下，扩展静态库项目，拖动xxxx.a到Targets下的Link Binary With Libraries。<br />
<a href="http://www.iphone-geek.cn/wp-content/uploads/2009/12/7.jpg"></a></li>
<p style="text-align: center;"><img class="alignnone size-full wp-image-507" title="7" src="http://www.iphone-geek.cn/wp-content/uploads/2009/12/7.jpg" alt="7" width="242" height="418" /></p>
</ol>
<p>&nbsp;</p>
<p>这样你就可以从当前项目下，双击静态库的项目来打开和修改静态库的代码了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/iphone%e9%a1%b9%e7%9b%ae%e4%bd%bf%e7%94%a8%e9%9d%99%e6%80%81%e5%ba%93%e7%9a%84%e6%9c%80%e4%bd%b3%e6%96%b9%e6%b3%95/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>iPhone静态库项目模板</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/iphone%e9%9d%99%e6%80%81%e5%ba%93%e9%a1%b9%e7%9b%ae%e6%a8%a1%e6%9d%bf</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/iphone%e9%9d%99%e6%80%81%e5%ba%93%e9%a1%b9%e7%9b%ae%e6%a8%a1%e6%9d%bf#comments</comments>
		<pubDate>Mon, 30 Nov 2009 01:28:05 +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=367</guid>
		<description><![CDATA[Xcode并未提供iPhone静态库的模板，所以我每次都使用Mac Application的静态库模板，但每次建立项目后，都要针对iPhone进行一些修改，比较麻烦。我在网上找到一个可以直接被iPhone项目使用的静态库模板：
见http://github.com/keremk/iphone-static-library-project-template。
]]></description>
			<content:encoded><![CDATA[<p>Xcode并未提供iPhone静态库的模板，所以我每次都使用Mac Application的静态库模板，但每次建立项目后，都要针对iPhone进行一些修改，比较麻烦。我在网上找到一个可以直接被iPhone项目使用的静态库模板：</p>
<p>见<a href="http://github.com/keremk/iphone-static-library-project-template">http://github.com/keremk/iphone-static-library-project-template</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/iphone%e9%9d%99%e6%80%81%e5%ba%93%e9%a1%b9%e7%9b%ae%e6%a8%a1%e6%9d%bf/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Xcode之宏</title>
		<link>http://www.iphone-geek.cn/%e6%8a%80%e5%b7%a7%e4%b8%8e%e6%8f%90%e7%a4%ba/xcode%e4%b9%8b%e5%ae%8f</link>
		<comments>http://www.iphone-geek.cn/%e6%8a%80%e5%b7%a7%e4%b8%8e%e6%8f%90%e7%a4%ba/xcode%e4%b9%8b%e5%ae%8f#comments</comments>
		<pubDate>Thu, 12 Nov 2009 04:30:54 +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=200</guid>
		<description><![CDATA[注：宏的使用可以节省代码重复输入工作，还可以为调试带来各种好处。本文列出了几个非常简单实用的宏。

&#160;
这些是我在Xcode中常用到的宏： 
&#160;
CMLog: 用它来代替NSLog：
1#define CMLog(format, ...) NSLog(@&#34;%s:%@&#34;, __PRETTY_FUNCTION__,[NSString stringWithFormat:format, ## __VA_ARGS__]);
&#160;
它的作用是将调用它的类和方法的名称一起输出到控制台。比如你在MyAppDelegate类的applicationDidFinishLaunching方法中调用它：
1CMLog&#40;@&#34;My iPhone is an %@, v %@&#34;, &#91;&#91;UIDevice currentDevice&#93; model&#93;, &#91;&#91;UIDevice currentDevice&#93; systemVersion&#93;&#41;;
&#160;
控制台将输出：
2009-01-05 10:06:28.957 MyApp15173:20b] -[MyAppDelegate applicationDidFinishLaunching:]:
My iPhone is an iPhone Simulator, v 2.2
&#160;
MARK: 此宏用于输出调用它的类和方法名称。适用于只想知道是否一个方法被调用了。
1#define MARK&#160; &#160; CMLog(@&#34;%s&#34;, __PRETTY_FUNCTION__);
&#160;
START_TIMER和END_TIMER: 用于确定一个方法或一段代码的运行时间：
12#define START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; &#160;
#define END_TIMER(msg) &#160;NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; CMLog([NSString stringWithFormat:@&#34;%@ Time [...]]]></description>
			<content:encoded><![CDATA[<p>注：宏的使用可以节省代码重复输入工作，还可以为调试带来各种好处。本文列出了几个非常简单实用的宏。<br />
<span id="more-200"></span></p>
<p>&nbsp;</p>
<p>这些是我在Xcode中常用到的宏： </p>
<p>&nbsp;</p>
<p><strong>CMLog</strong>: 用它来代替NSLog：</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"><span style="color: #6e371a;">#define CMLog(format, ...) NSLog(@&quot;%s:%@&quot;, __PRETTY_FUNCTION__,[NSString stringWithFormat:format, ## __VA_ARGS__]);</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<p>它的作用是将调用它的类和方法的名称一起输出到控制台。比如你在<strong>MyAppDelegate</strong>类的<strong>applicationDidFinishLaunching</strong>方法中调用它：</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">CMLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;My iPhone is an %@, v %@&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>UIDevice currentDevice<span style="color: #002200;">&#93;</span> model<span style="color: #002200;">&#93;</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><span style="color: #002200;">&#41;</span>;</div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<p>控制台将输出：</p>
<pre>2009-01-05 10:06:28.957 MyApp15173:20b] -[MyAppDelegate applicationDidFinishLaunching:]:
My iPhone is an iPhone Simulator, v 2.2</pre>
<p>&nbsp;</p>
<p><strong>MARK</strong>: 此宏用于输出调用它的类和方法名称。适用于只想知道是否一个方法被调用了。</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"><span style="color: #6e371a;">#define MARK&nbsp; &nbsp; CMLog(@&quot;%s&quot;, __PRETTY_FUNCTION__);</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<p><strong>START_TIMER</strong>和<strong>END_TIMER</strong>: 用于确定一个方法或一段代码的运行时间：</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 /></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;">#define START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; &nbsp;</span><br />
<span style="color: #6e371a;">#define END_TIMER(msg) &nbsp;NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; CMLog([NSString stringWithFormat:@&quot;%@ Time = %f&quot;;, msg, stop-start]);</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<p>将<strong>START_TIMER</strong> 置于需评测的代码段开始处，并将<strong>END_TIMER</strong>置于代码段结束处，你就可获得这段代码的运行时间：</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 /></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><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/"><span style="color: #400080;">NSData</span></a> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>loadDataFromURL<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>dataURL &nbsp;<br />
<span style="color: #002200;">&#123;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; START_TIMER; &nbsp; &nbsp;<br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/"><span style="color: #400080;">NSData</span></a> <span style="color: #002200;">*</span>data <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>self doSomeStuff<span style="color: #002200;">:</span>dataURL<span style="color: #002200;">&#93;</span>; &nbsp; &nbsp;<br />
&nbsp; &nbsp; END_TIMER<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;loadDataFromURL&quot;</span><span style="color: #002200;">&#41;</span>; &nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color: #a61390;">return</span> data; &nbsp;<br />
<span style="color: #002200;">&#125;</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<p>输出为:</p>
<pre>2009-01-05 10:31:37.943 MyApp[15283:20b] -[MyAppDelegate loadDataFromURL:]:
loadDataFromURL Time = 3.636021  </pre>
<p>&nbsp;</p>
<p>将所有这些宏定义整理使用条件标志放在预编译的头文件中。调试时，此标志设为1 ，发布时将其设为0 。</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 /></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;">#if DEBUG==1 &nbsp;</span><br />
&nbsp; &nbsp; <span style="color: #6e371a;">#define CMLog(format, ...) NSLog(@&quot;%s:%@&quot;;, __PRETTY_FUNCTION__,[NSString stringWithFormat:format, ## __VA_ARGS__]); &nbsp; </span><br />
&nbsp; &nbsp; <span style="color: #6e371a;">#define MARK&nbsp; &nbsp; CMLog(@&quot;%s&quot;;, __PRETTY_FUNCTION__); &nbsp;</span><br />
&nbsp; &nbsp; <span style="color: #6e371a;">#define START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; &nbsp;</span><br />
&nbsp; &nbsp; <span style="color: #6e371a;">#define END_TIMER(msg) &nbsp;NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; CMLog([NSString stringWithFormat:@&quot;%@ Time = %f&quot;;, msg, stop-start]); &nbsp;</span><br />
<span style="color: #6e371a;">#else &nbsp;</span><br />
&nbsp; &nbsp; <span style="color: #6e371a;">#define CMLog(format, ...) &nbsp;</span><br />
&nbsp; &nbsp; <span style="color: #6e371a;">#define MARK &nbsp;#define START_TIMER &nbsp;</span><br />
&nbsp; &nbsp; <span style="color: #6e371a;">#define END_TIMER(msg) &nbsp;</span><br />
<span style="color: #6e371a;">#endif</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<p>在<em>Debug</em>目标设定中加入：</p>
<pre>OTHER_CFLAGS = -DDEBUG=1  </pre>
<p>&nbsp;</p>
<p>在<em>Release</em> 目标设定中加入：</p>
<pre>OTHER_CFLAGS = -DDEBUG=0
</pre>
<p>&nbsp;</p>
<h5>
          原文见：<a href="http://blog.coriolis.ch/2009/01/05/macros-for-xcode/" rel="bookmark" title="Permanent Link: Macros for Xcode">Macros for Xcode</a><br />
        </h5>
<pre>&nbsp;        </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e6%8a%80%e5%b7%a7%e4%b8%8e%e6%8f%90%e7%a4%ba/xcode%e4%b9%8b%e5%ae%8f/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>怎样替换Xcode中__MyCompanyName__</title>
		<link>http://www.iphone-geek.cn/%e6%8a%80%e5%b7%a7%e4%b8%8e%e6%8f%90%e7%a4%ba/%e6%80%8e%e6%a0%b7%e6%9b%bf%e6%8d%a2xcode%e4%b8%ad__mycompanyname__</link>
		<comments>http://www.iphone-geek.cn/%e6%8a%80%e5%b7%a7%e4%b8%8e%e6%8f%90%e7%a4%ba/%e6%80%8e%e6%a0%b7%e6%9b%bf%e6%8d%a2xcode%e4%b8%ad__mycompanyname__#comments</comments>
		<pubDate>Wed, 11 Nov 2009 14:07:18 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[技巧与提示]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[提示与技巧]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=195</guid>
		<description><![CDATA[我们知道，Xcode在每个.h和.m文件头都会加上一些发行信息，如姓名，创建日期，公司名等。但公司名是用__MyCompanyName__代表，每个文件都要手工修改十分麻烦。此信息的模板存在/Library/Application Support/Apple/Developer Tools/File Templates下，格式如下：
12345678/*
&#160;* &#160;«FILENAME»
&#160;* &#160;«PROJECTNAME»
&#160;*
&#160;* &#160;Created by «FULLUSERNAME» on «DATE».
&#160;* &#160;Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
&#160;*
&#160;*/
我们当然可以修改此文件。但每次Xcode升级后，此信息就会丢失。我在一本有关Xcode的书中找到一个方法：
1defaults write com.apple.xcode PBXCustomTemplateMacroDefinitions '{ ORGANIZATIONNAME = &#34;Joan Smith&#34;; }'
另一种方法是通过双击~/Library/Preferences下com.apple.Xcode.plist来修改。
]]></description>
			<content:encoded><![CDATA[<p>我们知道，Xcode在每个.h和.m文件头都会加上一些发行信息，如姓名，创建日期，公司名等。但公司名是用__MyCompanyName__代表，每个文件都要手工修改十分麻烦。此信息的模板存在/Library/Application Support/Apple/Developer Tools/File Templates下，格式如下：</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 /></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;">/*<br />
&nbsp;* &nbsp;«FILENAME»<br />
&nbsp;* &nbsp;«PROJECTNAME»<br />
&nbsp;*<br />
&nbsp;* &nbsp;Created by «FULLUSERNAME» on «DATE».<br />
&nbsp;* &nbsp;Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.<br />
&nbsp;*<br />
&nbsp;*/</span></div></td></tr></tbody></table></div>
<p>我们当然可以修改此文件。但每次Xcode升级后，此信息就会丢失。我在一本有关Xcode的书中找到一个方法：</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">defaults write com.apple.xcode PBXCustomTemplateMacroDefinitions <span style="color: #bf1d1a;">'{ ORGANIZATIONNAME = &quot;Joan Smith&quot;; }'</span></div></td></tr></tbody></table></div>
<p>另一种方法是通过双击~/Library/Preferences下com.apple.Xcode.plist来修改。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e6%8a%80%e5%b7%a7%e4%b8%8e%e6%8f%90%e7%a4%ba/%e6%80%8e%e6%a0%b7%e6%9b%bf%e6%8d%a2xcode%e4%b8%ad__mycompanyname__/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Xcode提示与技巧1-10</title>
		<link>http://www.iphone-geek.cn/%e6%8a%80%e5%b7%a7%e4%b8%8e%e6%8f%90%e7%a4%ba/xcode%e6%8f%90%e7%a4%ba%e4%b8%8e%e6%8a%80%e5%b7%a71-10</link>
		<comments>http://www.iphone-geek.cn/%e6%8a%80%e5%b7%a7%e4%b8%8e%e6%8f%90%e7%a4%ba/xcode%e6%8f%90%e7%a4%ba%e4%b8%8e%e6%8a%80%e5%b7%a71-10#comments</comments>
		<pubDate>Fri, 30 Oct 2009 13:15:28 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[技巧与提示]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://iphonegeekbeta.zuesitech.com/?p=112</guid>
		<description><![CDATA[
我的世界被各种各样的便签条，不管是电子的还是纸的，包围着。我总是想方设法记住各种各样的Xcode的便捷键以及各种提示与技巧。编程时，我总是尽量少用鼠标，如果没有这些提示，我就会无所适从了。而这里是记录这些提示与技巧最好的地方了。


    这是第一篇文章，我希望接下来会有更多有关Xcode的提示与技巧文章。
  
&#160;
提示 #1 &#8211; 垂直分割编辑器视图

    如果你喜欢同时使用多代码窗口，编辑器分割选项可以帮助你（留意下图中小正方形网格图标）。
  

  
  缺省情况下，窗口被水平分割。如果你希望并列观察你的代码（便于比较），下面是关于怎样垂直分割窗口的方法：

  &#160;&#160;&#160;&#160;1.按下窗口分割图标的同时按下Option键。

&#160;
    提示 #2 &#8211; 解除一段代码的注解

  你可以按下面方法快速为一段代码加注解：

    &#160;&#160;&#160;&#160;1.选择需加注解的一行或多行代码
  &#160;&#160;&#160;&#160;2.按Command-/

    要解除一段代码的注解，重复上述步骤。
  

&#160;
  提示 #3 &#8211; 在.h和.m文件间切换  

  在当前代码窗，按下面方法在.h和.m间快速切换：

    [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>我的世界被各种各样的便签条，不管是电子的还是纸的，包围着。我总是想方设法记住各种各样的Xcode的便捷键以及各种提示与技巧。编程时，我总是尽量少用鼠标，如果没有这些提示，我就会无所适从了。而这里是记录这些提示与技巧最好的地方了。</p>
<p><span id="more-112"></span></p>
<p>
    这是第一篇文章，我希望接下来会有更多有关Xcode的提示与技巧文章。
  </p>
<p>&nbsp;</p>
<h3><strong>提示 #1 &#8211; 垂直分割编辑器视图</strong></h3>
<p>
    如果你喜欢同时使用多代码窗口，编辑器分割选项可以帮助你（留意下图中小正方形网格图标）。
  </p>
<p>
  <img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/split1.png" alt=""></p>
<p>  缺省情况下，窗口被水平分割。如果你希望并列观察你的代码（便于比较），下面是关于怎样垂直分割窗口的方法：</p>
<p>
  &nbsp;&nbsp;&nbsp;&nbsp;1.按下窗口分割图标的同时按下<strong>Option</strong>键。</p>
<h3></p>
<p>&nbsp;</p>
<p>    提示 #2 &#8211; 解除一段代码的注解</h3>
<p>
  你可以按下面方法快速为一段代码加注解：</p>
<p>
    &nbsp;&nbsp;&nbsp;&nbsp;1.选择需加注解的一行或多行代码<br />
  &nbsp;&nbsp;&nbsp;&nbsp;2.按<strong>Command-/</strong></p>
<p>
    要解除一段代码的注解，重复上述步骤。
  </p>
<h3></p>
<p>&nbsp;</p>
<p>  提示 #3 &#8211; 在.h和.m文件间切换  </h3>
<p>
  在当前代码窗，按下面方法在.h和.m间快速切换：</p>
<p>
      &nbsp;&nbsp;&nbsp;&nbsp;1.<strong>Command-Option Up-Arrow</strong></p>
<p>&nbsp;</p>
<h3>提示 #4 &#8211; 键和动作映射（键绑定）</h3>
<p>
  上面的提示确实可以节省不少时间。但是，我发现我更喜欢按习惯将动作映射到按键上。例如，我可以将上一个提示的动作映射为<strong>Option-S</strong>，就像大部分的切换和交换动作 一样。</p>
<p>
  下面是怎样在Xcode中进行键绑定：</p>
<p>
        &nbsp;&nbsp;&nbsp;&nbsp;1.在Xcode菜单上选择<strong>Prefereces</strong>（偏好）<br />
      &nbsp;&nbsp;&nbsp;&nbsp;2.选择<strong>Key Bindings</strong>（键绑定）<br />
      &nbsp;&nbsp;&nbsp;&nbsp;3.单击列表中的一个<strong>Actions</strong>（动作）<br />
      &nbsp;&nbsp;&nbsp;&nbsp;4.轻击右边的<strong>Keys</strong>栏目<br />
      &nbsp;&nbsp;&nbsp;&nbsp;5.输入你希望映射到这个动作的按键<br />
      &nbsp;&nbsp;&nbsp;&nbsp;6.按<strong>Ok</strong>保存你的改变</p>
<h3></p>
<p>&nbsp;</p>
<p>  提示 #5 &ndash; 打开API文档  </h3>
<p>
  显示任何相关的SDK中的API文档十分简单：</p>
<p>
      &nbsp;&nbsp;&nbsp;&nbsp;1.在相关代码上双击<strong>Option</strong>键</p>
<p>
  例如，在下面截屏中，在双击<strong>UIToolbar</strong>后，一个弹出窗口将显示出此类的概要。</p>
<p>
  <img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/toolbar.png" alt=""></p>
<h3></p>
<p>&nbsp;</p>
<p>    提示 #6 &ndash; 历遍文件历史</h3>
<p>
    当你打开编辑各文件时，Xcode会象使用网页浏览器一样保留一份有关动作的历史清单。你可以象下图那样使用方向键头在清单中移动：</p>
<p>
    <img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/history.png" alt="">
  </p>
<p>
  与上述等效的键击如下：</p>
<p>
        &nbsp;&nbsp;&nbsp;&nbsp;1.<strong>Option-Command Left-Arrow</strong> 移动到前一个文件<br />
      &nbsp;&nbsp;&nbsp;&nbsp;2.<strong>Option-Command Right-Arrow</strong> 移动到下一个文件</p>
<h3></p>
<p>&nbsp;</p>
<p>  提示 #7 &ndash; 书签设定</h3>
<p>
  我简直无法想象编程时如果没有办法进行书签设定会怎样。当我要继续到另一个文件中查找某一段代码时，我经常需要进行书签设定。加书签很简单：</p>
<p>
        &nbsp;&nbsp;&nbsp;&nbsp;1.<strong>Control-D</strong><br />
      &nbsp;&nbsp;&nbsp;&nbsp;2.输入书签名</p>
<h3></p>
<p>&nbsp;</p>
<p>    提示 #8 &ndash; 跳转到书签</h3>
<p>
    有两种方法跳转到书签。第一种，你可以选择编辑器窗口右上角的书签图标。</p>
<p>
    <img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/bookmarks.png" alt="">
  </p>
<p>使用以下键击，你可以得到与上图相同的菜单：</p>
<p>
      &nbsp;&nbsp;&nbsp;&nbsp;1.<strong>Control-4</strong></p>
<h3></p>
<p>&nbsp;</p>
<p>    提示 #9 &ndash; 缩进/取消缩进</h3>
<p>
  你可以按以下方法缩进一行或一段选择的代码：</p>
<p>
        &nbsp;&nbsp;&nbsp;&nbsp;1.<strong>Command-[</strong> 向左移动代码<br />
      &nbsp;&nbsp;&nbsp;&nbsp;2.<strong>Command-]</strong> 向右移动代码</p>
<p>
    上述方法不管你处于代码行中的什么位置都会起作用，换而言之，你不必处于一行的开始处。
  </p>
<h3></p>
<p>&nbsp;</p>
<h3><strong>提示 #10 &ndash; 缩放编辑器</strong></h3>
<p>
    你可以通过按如下图所示的Editor（编辑器）按钮在细节视图和编辑器视图间切换。</p>
<p>
  <img src="http://iPhoneDeveloperTips.com/wp-content/uploads/2009/10/zoomeditor.png" alt=""></p>
<p>
  与以上等效的键击为：</p>
<p>
      &nbsp;&nbsp;&nbsp;&nbsp;1.<strong>Shift-Command-E</strong></p>
</div>
<p>&nbsp;</p>
<div>
<h5>
  原文来自：<a href="http://iPhoneDeveloperTips.com/xcode/xcode-tips-and-tricks-tips-1-to-10.html" rel="bookmark" title="Permanent Link: Killer Xcode Tips and Tricks &ndash; Tips 1 to 10">Killer Xcode Tips and Tricks &ndash; Tips 1 to 10</a><a href="http://iPhoneDeveloperTips.com/category/xcode" title="View all posts in Xcode" rel="category tag"></a> 翻译：bagusflyer</h5>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e6%8a%80%e5%b7%a7%e4%b8%8e%e6%8f%90%e7%a4%ba/xcode%e6%8f%90%e7%a4%ba%e4%b8%8e%e6%8a%80%e5%b7%a71-10/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
