<?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>Elton&#039;s Blog &#187; iPhone</title>
	<atom:link href="http://blog.prosight.me/index.php/tag/iphone-mac/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.prosight.me</link>
	<description>移动开发，敏捷web开发，Linux服务器部署维护，web UI和UE设计，摄影</description>
	<lastBuildDate>Wed, 08 Feb 2012 00:22:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>iPhone/Mac Objective-C内存管理教程和原理剖析(四)系统自动创建新的autorelease pool</title>
		<link>http://blog.prosight.me/index.php/2010/07/633?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iphonemac-objective-c%25e5%2586%2585%25e5%25ad%2598%25e7%25ae%25a1%25e7%2590%2586%25e6%2595%2599%25e7%25a8%258b%25e5%2592%258c%25e5%258e%259f%25e7%2590%2586%25e5%2589%2596%25e6%259e%2590%25e5%259b%259b%25e7%25b3%25bb%25e7%25bb%259f%25e8%2587%25aa%25e5%258a%25a8%25e5%2588%259b%25e5%25bb%25ba%25e6%2596%25b0</link>
		<comments>http://blog.prosight.me/index.php/2010/07/633#comments</comments>
		<pubDate>Thu, 29 Jul 2010 06:37:43 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[内存管理]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=633</guid>
		<description><![CDATA[四 系统自动创建新的autorelease pool 在生成新的Run Loop的时候，系统会自动创建新的autorelease pool（非常感谢网友hhyytt和neogui的提醒）。注意，此处不同于xcode在新建项目时自动生成的代码中加入的autorelease pool，xcode生成的代码可以被删除，但系统自动创建的新的autorelease pool是无法删除的（对于无Garbage Collection的环境来说）。Objective-C没有给出实现代码，官方文档也没有说明，但我们可以通过小程序来证明。 在这个小程序中，我们先生成了一个autorelease pool，然后生成一个autorelease的ClassA的实例，再在一个新的run loop中生成一个autorelease的ClassB的对象（注意，我们并没有手动在新run loop中生成autorelease pool）。精简的示例代码如下，详细代码请见附件中的memman-run-loop-with-pool.m。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 int main&#40;int argc, char**argv&#41; &#123; NSLog&#40;@&#34;create an autorelasePooln&#34;&#41;; NSAutoreleasePool *pool = &#91;&#91;NSAutoreleasePool alloc&#93; init&#93;; &#160; NSLog&#40;@&#34;create [...]]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/07/633/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>iPhone/Mac Objective-C内存管理教程和原理剖析(三)@property (retain)和@synthesize的默认实现</title>
		<link>http://blog.prosight.me/index.php/2010/07/630?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iphonemac-objective-c%25e5%2586%2585%25e5%25ad%2598%25e7%25ae%25a1%25e7%2590%2586%25e6%2595%2599%25e7%25a8%258b%25e5%2592%258c%25e5%258e%259f%25e7%2590%2586%25e5%2589%2596%25e6%259e%2590%25e4%25b8%2589property-retain%25e5%2592%258csynthesize%25e7%259a%2584%25e9%25bb%2598%25e8%25ae%25a4</link>
		<comments>http://blog.prosight.me/index.php/2010/07/630#comments</comments>
		<pubDate>Thu, 29 Jul 2010 06:29:50 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[内存管理]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=630</guid>
		<description><![CDATA[三 @property (retain)和@synthesize的默认实现 在这里解释一下@property (retain) ClassB* objB;和@synthesize objB;背后到底发生了什么(retain property的默认实现)。property实际上是getter和setter，针对有retain参数的property，背后的实现如下（请参考附件中的memman-getter-setter.m，你会发现，结果和memman-property.m一样）： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 @interface ClassA : NSObject &#123; ClassB *objB; &#125; &#160; -&#40;ClassB *&#41; getObjB; -&#40;void&#41; setObjB:&#40;ClassB *&#41; value; @end &#160; @implementation ClassA -&#40;ClassB*&#41; getObjB &#123; [...]]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/07/630/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone/Mac Objective-C内存管理教程和原理剖析(二)口诀与范式</title>
		<link>http://blog.prosight.me/index.php/2010/07/628?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iphonemac-objective-c%25e5%2586%2585%25e5%25ad%2598%25e7%25ae%25a1%25e7%2590%2586%25e6%2595%2599%25e7%25a8%258b%25e5%2592%258c%25e5%258e%259f%25e7%2590%2586%25e5%2589%2596%25e6%259e%2590%25e4%25ba%258c%25e5%258f%25a3%25e8%25af%2580%25e4%25b8%258e%25e8%258c%2583%25e5%25bc%258f</link>
		<comments>http://blog.prosight.me/index.php/2010/07/628#comments</comments>
		<pubDate>Thu, 29 Jul 2010 03:38:19 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[内存管理]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=628</guid>
		<description><![CDATA[二 口诀与范式 1 口诀。 1.1 谁创建，谁释放（类似于“谁污染，谁治理”）。如果你通过alloc、new或copy来创建一个对象，那么你必须调用release或autorelease。换句话说，不是你创建的，就不用你去释放。 例如，你在一个函数中alloc生成了一个对象，且这个对象只在这个函数中被使用，那么你必须在这个函数中调用release或autorelease。如果你在一个class的某个方法中alloc一个成员对象，且没有调用autorelease，那么你需要在这个类的dealloc方法中调用release；如果调用了autorelease，那么在dealloc方法中什么都不需要做。 1.2 除了alloc、new或copy之外的方法创建的对象都被声明了autorelease。 1.3 谁retain，谁release。只要你调用了retain，无论这个对象是如何生成的，你都要调用release。有时候你的代码中明明没有retain，可是系统会在默认实现中加入retain。不知道为什么苹果公司的文档没有强调这个非常重要的一点，请参考范式2.7和第三章。 2 范式。 范式就是模板，就是依葫芦画瓢。由于不同人有不同的理解和习惯，我总结的范式不一定适合所有人，但我能保证照着这样做不会出问题。 2.1 创建一个对象。 1 ClassA *obj1 = &#91;&#91;ClassA alloc&#93; init&#93;; 2.2 创建一个autorelease的对象。 1 ClassA *obj1 = &#91;&#91;&#91;ClassA alloc&#93; init&#93; autorelease&#93;; 2.3 Release一个对象后，立即把指针清空。（顺便说一句，release一个空指针是合法的，但不会发生任何事情） 1 2 &#91;obj1 release&#93;; obj1 = nil; 2.4 指针赋值给另一个指针。 1 2 3 4 5 ClassA *obj2 = obj1; &#91;obj2 retain&#93;; [...]]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/07/628/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>iPhone/Mac Objective-C内存管理教程和原理剖析(一)基本原理</title>
		<link>http://blog.prosight.me/index.php/2010/07/625?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iphonemac-objective-c%25e5%2586%2585%25e5%25ad%2598%25e7%25ae%25a1%25e7%2590%2586%25e6%2595%2599%25e7%25a8%258b%25e5%2592%258c%25e5%258e%259f%25e7%2590%2586%25e5%2589%2596%25e6%259e%2590%25e4%25b8%2580%25e5%259f%25ba%25e6%259c%25ac%25e5%258e%259f%25e7%2590%2586</link>
		<comments>http://blog.prosight.me/index.php/2010/07/625#comments</comments>
		<pubDate>Thu, 29 Jul 2010 03:05:28 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[内存管理]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=625</guid>
		<description><![CDATA[前言 初学objectice-C的朋友都有一个困惑，总觉得对objective-C的内存管理机制琢磨不透，程序经常内存泄漏或莫名其妙的崩溃。我在这里总结了自己对objective-C内存管理机制的研究成果和经验，写了这么一个由浅入深的教程。希望对大家有所帮助，也欢迎大家一起探讨。 此文涉及的内存管理是针对于继承于NSObject的Class。 一 基本原理 Objective-C的内存管理机制与.Net/Java那种全自动的垃圾回收机制是不同的，它本质上还是C语言中的手动管理方式，只不过稍微加了一些自动方法。 1 Objective-C的对象生成于堆之上，生成之后，需要一个指针来指向它。 1 ClassA *obj1 = &#91;&#91;ClassA alloc&#93; init&#93;; 2 Objective-C的对象在使用完成之后不会自动销毁，需要执行dealloc来释放空间（销毁），否则内存泄露。 1 &#91;obj1 dealloc&#93;; 这带来了一个问题。下面代码中obj2是否需要调用dealloc？ 1 2 3 4 5 6 ClassA *obj1 = &#91;&#91;ClassA alloc&#93; init&#93;; ClassA *obj2 = obj1; &#91;obj1 hello&#93;; //输出hello &#91;obj1 dealloc&#93;; &#91;obj2 hello&#93;; //能够执行这一行和下一行吗？ &#91;obj2 dealloc&#93;; 不能，因为obj1和obj2只是指针，它们指向同一个对象，[obj1 dealloc]已经销毁这个对象了，不能再调用[obj2 hello]和[obj2 dealloc]。obj2实际上是个无效指针。 如何避免无效指针？请看下一条。 3 Objective-C采用了引用计数(ref count或者retain [...]]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/07/625/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何配置iAd</title>
		<link>http://blog.prosight.me/index.php/2010/06/612?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%25a6%2582%25e4%25bd%2595%25e9%2585%258d%25e7%25bd%25aeiad</link>
		<comments>http://blog.prosight.me/index.php/2010/06/612#comments</comments>
		<pubDate>Tue, 29 Jun 2010 02:35:23 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iAd]]></category>
		<category><![CDATA[iOS4]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=612</guid>
		<description><![CDATA[1. 导入iAd.framework 2.选择要定制iAd的TabViewController.h ， 添加代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #import &#60;UIKit/UIKit.h&#62; #import &#60;iAd/ADBannerView.h&#62; @interface TabViewController : UIViewController&#60;ADBannerViewDelegate&#62; &#123; ADBannerView *adView; UILabel *adStatus; &#125; - &#40;void&#41;bannerViewDidLoadAd:&#40;ADBannerView *&#41;banner; - &#40;BOOL&#41;bannerViewActionShouldBegin:&#40;ADBannerView *&#41;banner willLeaveApplication:&#40;BOOL&#41;willLeave; - &#40;void&#41;bannerViewActionDidFinish:&#40;ADBannerView *&#41;banner; - &#40;void&#41;bannerView:&#40;ADBannerView *&#41; didFailToReceiveAdWithError:&#40;NSError *&#41;error; - &#40;void&#41;adAvailabilityDidChange; @property &#40;nonatomic, retain&#41; ADBannerView *adView; [...]]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/06/612/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>如何在iPhone图标上加提示符(badge)</title>
		<link>http://blog.prosight.me/index.php/2010/02/584?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%25a6%2582%25e4%25bd%2595%25e5%259c%25a8iphone%25e5%259b%25be%25e6%25a0%2587%25e4%25b8%258a%25e5%258a%25a0%25e6%258f%2590%25e7%25a4%25ba%25e7%25ac%25a6badge</link>
		<comments>http://blog.prosight.me/index.php/2010/02/584#comments</comments>
		<pubDate>Sun, 21 Feb 2010 00:57:42 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[badge]]></category>
		<category><![CDATA[setApplicationIconBadgeNumber]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=584</guid>
		<description><![CDATA[如果你使用Apple iPhone自带的Mail程序，你会注意到，当有新邮件的时候，在这个程序的图标(icon)上会显示对应的新邮件的数字。 如果你的应用程序也想有类似的功能，其实很简单： 1 2 3 4 - &#40;void&#41;applicationDidFinishLaunching:&#40;UIApplication *&#41;application &#123; //... &#91;application setApplicationIconBadgeNumber:123&#93;; &#125;]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/02/584/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>将Array、Dictionary等集合类的序列化和反序列化</title>
		<link>http://blog.prosight.me/index.php/2010/02/582?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%25b0%2586array%25e3%2580%2581dictionary%25e7%25ad%2589%25e9%259b%2586%25e5%2590%2588%25e7%25b1%25bb%25e7%259a%2584%25e5%25ba%258f%25e5%2588%2597%25e5%258c%2596%25e5%2592%258c%25e5%258f%258d%25e5%25ba%258f%25e5%2588%2597%25e5%258c%2596</link>
		<comments>http://blog.prosight.me/index.php/2010/02/582#comments</comments>
		<pubDate>Mon, 15 Feb 2010 12:43:17 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[NSArray]]></category>
		<category><![CDATA[NSDictionary]]></category>
		<category><![CDATA[writeToFile]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=582</guid>
		<description><![CDATA[Objective-C的集合类序列化到文件中或者从文件中反序列化其实很简单，请看下面的示例代码： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 NSArray *array = &#91;NSArray arrayWithObjects: @&#34;Hefeweizen&#34;, @&#34;IPA&#34;, @&#34;Pilsner&#34;, @&#34;Stout&#34;, nil&#93;; &#160; NSDictionary *dictionary = &#91;NSDictionary dictionaryWithObjectsAndKeys: array, @&#34;array&#34;, [...]]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/02/582/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>创建没有按钮的UIAlertView</title>
		<link>http://blog.prosight.me/index.php/2010/02/580?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%2588%259b%25e5%25bb%25ba%25e6%25b2%25a1%25e6%259c%2589%25e6%258c%2589%25e9%2592%25ae%25e7%259a%2584uialertview</link>
		<comments>http://blog.prosight.me/index.php/2010/02/580#comments</comments>
		<pubDate>Thu, 11 Feb 2010 13:48:14 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[UIAlertView]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=580</guid>
		<description><![CDATA[默认的，UIAlertView都有一个或者多个按钮，如果你想创建没有按钮的UIAlertView，可以使用以下的方法： 1 2 3 4 5 6 7 8 UIAlertView *alert; &#160; ... &#160; alert = &#91;&#91;&#91;UIAlertView alloc&#93; initWithTitle:@&#34;Configuring PreferencesnPlease Wait...&#34; message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil&#93; autorelease&#93;; &#160; &#91;alert show&#93;; 上面的标题可能有些靠上，可以用过给标题增加回车的方式，使标题居中： 1 2 3 4 5 6 7 8 UIAlertView *alert; &#160; ... &#160; alert = &#91;&#91;&#91;UIAlertView alloc&#93; initWithTitle:@&#34;nnConfiguring PreferencesnPlease Wait...&#34; message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: [...]]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/02/580/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>去掉iPhone应用图标上的弧形高光</title>
		<link>http://blog.prosight.me/index.php/2010/01/566?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=%25e5%258e%25bb%25e6%258e%2589iphone%25e5%25ba%2594%25e7%2594%25a8%25e5%259b%25be%25e6%25a0%2587%25e4%25b8%258a%25e7%259a%2584%25e5%25bc%25a7%25e5%25bd%25a2%25e9%25ab%2598%25e5%2585%2589</link>
		<comments>http://blog.prosight.me/index.php/2010/01/566#comments</comments>
		<pubDate>Mon, 25 Jan 2010 03:30:08 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[ICON]]></category>
		<category><![CDATA[Info.plist]]></category>
		<category><![CDATA[UIPrerenderedIcon]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=566</guid>
		<description><![CDATA[有时候我们的应用程序不需要在图标上加上默认的高光，可以在你的应用的Info.plist中加入： 1 UIPrerenderedIcon，让它等于YES即可]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/01/566/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>让你的iPhone应用的URL更加友好易记</title>
		<link>http://blog.prosight.me/index.php/2010/01/562?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=562</link>
		<comments>http://blog.prosight.me/index.php/2010/01/562#comments</comments>
		<pubDate>Mon, 25 Jan 2010 01:20:08 +0000</pubDate>
		<dc:creator>Elton</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[App]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://blog.prosight.me/?p=562</guid>
		<description><![CDATA[在你的应用程序上线后，经常要做对外推广的工作，经常会把你的应用程序的url贴在各处。 默认的iTunes链接的样子如下： 1 http://itunes.apple.com/us/app/china-charming-girl/id348850577?mt=8 比较长，而且对搜索引擎不是很友好。 其实iTunes的url可以有很三种方式： 公司名字 http://itunes.com/apps/ (例如, http://itunes.com/apps/prosight) 应用程序名字 http://itunes.com/apps/ (例如, http://itunes.com/apps/crazyfart) 应用程序名加公司名 http://itunes.com/apps// (例如, http://itunes.com/apps/prosight/crazyfart) 生成这个url有如下规则： 移除所有的空格 移除所有的copyright (©), trademark (™) 和registered mark (®) 符号 替换”&#38;” 成 “and” 移除所有非法字符（见下） 替换所有非英语字符(ü, å, etc.) 为英文字符 (u, a, etc.) 保留所有其他的字符 非法字符： 1 !¡&#34;#$%'()*+,-./:;&#38;lt;=&#38;gt;¿?@[]^_`{&#124;}~]]></description>
		<wfw:commentRss>http://blog.prosight.me/index.php/2010/01/562/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

