<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_不及格的程序员-八神</title><subtitle type="text"/><id>http://feed.cnblogs.com/blog/u/50829/rss</id><updated>2012-05-31T07:36:29Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><generator>feed.cnblogs.com</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/50829/rss"/><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528549.html</id><title type="text">Webkit CSS Effect Example</title><summary type="text"/><published>2012-05-31T07:36:00Z</published><updated>2012-05-31T07:36:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528549.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528549.html"/><content type="html">&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053115335891.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053115351979.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053115353419.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053115360016.png" alt="" /&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2528549.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528549.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528501.html</id><title type="text">Device tokens</title><summary type="text">Generated by APNs for each deviceDifferent from UDID entered into Program PortalDevice token value may changeApp is restored to a new deviceSame device is erased then app is reinstalled without restore uniquely identifies deviceCall registration API at each app launch and then send to server every t</summary><published>2012-05-31T07:16:00Z</published><updated>2012-05-31T07:16:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528501.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528501.html"/><content type="html">&lt;ul&gt;&lt;li&gt;Generated by APNs for each device&lt;/li&gt;&lt;li&gt;Different from UDID entered into Program Portal&lt;/li&gt;&lt;li&gt;Device token value may change&lt;ul&gt;&lt;li&gt;App is restored to a new device&lt;/li&gt;&lt;li&gt;Same device is erased then app is reinstalled without restore uniquely identifies device&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Call registration API at each app launch and then send to server every time&lt;/li&gt;&lt;li&gt;Development device token != production device token&lt;/li&gt;&lt;/ul&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2528501.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528501.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528481.html</id><title type="text">illustrate ARC with graphs</title><summary type="text"/><published>2012-05-31T07:03:00Z</published><updated>2012-05-31T07:03:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528481.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528481.html"/><content type="html">&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114533722.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114540065.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114550450.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114554259.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114560453.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114564428.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114571352.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114573759.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114582452.png" alt="" /&gt;&lt;br /&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114575942.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114590220.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053114594915.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053115002324.png" alt="" /&gt;&lt;/p&gt;&lt;p&gt;&lt;img src="http://pic002.cnblogs.com/images/2012/47234/2012053115005841.png" alt="" /&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2528481.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/05/31/2528481.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/05/30/2526240.html</id><title type="text">Including QuickTime Movies In A Web Page</title><summary type="text">Including QuickTime Movies In A Web PageNow that you've finished compressing your movie, you can deploy it to the web.QuickTime movies can be included in a web page allowing visitors to your website to experience media seamlessly inside their browser. This is accomplished by adding some HTML to </summary><published>2012-05-30T06:22:00Z</published><updated>2012-05-30T06:22:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/30/2526240.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/30/2526240.html"/><content type="html">&lt;div id="LC1" class="line"&gt;&lt;h2 class="jump"&gt;Including QuickTime Movies In A Web Page&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Now that you've finished compressing your movie, you can deploy it to the web.&lt;/p&gt;&lt;p&gt;QuickTime movies can be included in a web page allowing visitors to your website to experience media seamlessly inside their browser. This is accomplished by adding some HTML to your web page that tells the QuickTime browser plug-in to display the media. See the&amp;nbsp;&lt;span class="content_text"&gt;&lt;a class="urlLink" href="http://www.apple.com/quicktime/tutorials/embed.html" rel="external" target="_blank"&gt;Including QuickTime In A Web Page Tutorial&lt;/a&gt;&lt;/span&gt;&amp;nbsp;to learn more.&lt;/p&gt;&lt;a title="Specifying Multiple Movie Targets using Reference Movies" name="//apple_ref/doc/uid/DTS40007625-CH1-SUBSECTION22"&gt;&lt;/a&gt;&lt;h3 class="jump"&gt;Specifying Multiple Movie Targets using Reference Movies&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;If you have more than one target, you should compress your movie more than once. Compressing multiple versions of a movie takes time, and posting multiple versions uses disk space. But it makes a better experience for your users. If you can spend the time and have the space, compress different versions and target them using what is called a&amp;nbsp;&lt;strong&gt;reference movie&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;A reference movie contains pointers to alternate data rate movies--that is, multiple versions of the movie designed for downloading at various data rates. These alternate data rate movies do not typically all reside in the same reference movie file (although you may optionally "flatten" any of these movies into the reference movie so that they are all contained within the same file); any others are included by reference only.&lt;/p&gt;&lt;p&gt;For example, a QuickTime movie can contain a list of references to movies having different data rates, allowing an application to choose the best-looking movie that can play smoothly as it downloads over the Internet, based on the user&amp;rsquo;s connection speed.&lt;/p&gt;&lt;p&gt;Here's an example: to target iPod Touch and iPhone over EDGE/Wi-Fi you could create two versions of your movie with different data rates as shown in&amp;nbsp;&lt;span class="content_text"&gt;Table 10&lt;/span&gt;&amp;nbsp;and then create a reference movie that targets them based on connection speed:&lt;/p&gt;&lt;a title="Table 10Creating Multiple Versions of a Movie to target iPod Touch and iPhone over EDGE/Wi-Fi." name="//apple_ref/doc/uid/DTS40007625-CH1-TABLE10"&gt;&lt;/a&gt;&lt;div class="tableholder"&gt;&lt;table class="graybox" border="0" cellspacing="0" cellpadding="5"&gt;&lt;caption class="tablecaption"&gt;&lt;strong class="caption_number"&gt;Table 10&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Creating Multiple Versions of a Movie to target iPod Touch and iPhone over EDGE/Wi-Fi.&lt;/caption&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th class="TableHeading_TableRow_TableCell" scope="col"&gt;&lt;p&gt;Movie Size&lt;/p&gt;&lt;/th&gt;&lt;th class="TableHeading_TableRow_TableCell" scope="col"&gt;&lt;p&gt;Device&lt;/p&gt;&lt;/th&gt;&lt;th class="TableHeading_TableRow_TableCell" scope="col"&gt;&lt;p&gt;Total Bit Rate&lt;/p&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&lt;p&gt;400 X 225&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;iPhone/iPod Touch over Wi-Fi&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;714kb&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&lt;p&gt;400 X 225&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;iPhone over EDGE&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;112kb&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;You can use the&amp;nbsp;&lt;span class="content_text"&gt;&lt;a class="urlLink" href="https://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wa/getSoftware?bundleID=19980" rel="external" target="_blank"&gt;MakeRefMovie&lt;/a&gt;&lt;/span&gt;&amp;nbsp;tool to create a reference movie.&lt;/p&gt;&lt;p&gt;See the&amp;nbsp;&lt;span class="content_text"&gt;&lt;a class="urlLink" href="http://www.apple.com/quicktime/tutorials/refmovies.html" rel="external" target="_blank"&gt;Reference Movies Tutorial&lt;/a&gt;&lt;/span&gt;&amp;nbsp;to learn how to use the MakeRefMovie tool to create a reference movie.&lt;/p&gt;&lt;p&gt;The alternative is to optimize compression for one delivery medium at the expense of the others; you can compress for delivery over a slow connection, for example, with lower quality than you could provide to people with faster connections, and let people with slower connections wait a bit longer to see the movie. Some people would rather wait however long it takes to get the best-quality movie, so if you use alternate movies, you might want to include a way for people to download the high-bandwidth version, regardless of their connection speed.&lt;/p&gt;&lt;p&gt;For example, when targeting Apple TV you can provide a separate download to allow users to get the high bandwidth version of your movie as shown here:&lt;/p&gt;&lt;a title="Table 11Movie Download for Apple TV." name="//apple_ref/doc/uid/DTS40007625-CH1-TABLE11"&gt;&lt;/a&gt;&lt;div class="tableholder"&gt;&lt;table class="graybox" border="0" cellspacing="0" cellpadding="5"&gt;&lt;caption class="tablecaption"&gt;&lt;strong class="caption_number"&gt;Table 11&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Movie Download for Apple TV.&lt;/caption&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th class="TableHeading_TableRow_TableCell" scope="col"&gt;&lt;p&gt;Movie Size&lt;/p&gt;&lt;/th&gt;&lt;th class="TableHeading_TableRow_TableCell" scope="col"&gt;&lt;p&gt;Device&lt;/p&gt;&lt;/th&gt;&lt;th class="TableHeading_TableRow_TableCell" scope="col"&gt;&lt;p&gt;Total Bit Rate&lt;/p&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&lt;p&gt;1280 X 720&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;Apple TV HD&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;5Mb&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;Here's the download for iPod:&lt;/p&gt;&lt;a title="Table 12Movie Download for iPod." name="//apple_ref/doc/uid/DTS40007625-CH1-TABLE12"&gt;&lt;/a&gt;&lt;div class="tableholder"&gt;&lt;table class="graybox" border="0" cellspacing="0" cellpadding="5"&gt;&lt;caption class="tablecaption"&gt;&lt;strong class="caption_number"&gt;Table 12&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Movie Download for iPod.&lt;/caption&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th class="TableHeading_TableRow_TableCell" scope="col"&gt;&lt;p&gt;Movie Size&lt;/p&gt;&lt;/th&gt;&lt;th class="TableHeading_TableRow_TableCell" scope="col"&gt;&lt;p&gt;Device&lt;/p&gt;&lt;/th&gt;&lt;th class="TableHeading_TableRow_TableCell" scope="col"&gt;&lt;p&gt;Total Bit Rate&lt;/p&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&lt;p&gt;640 X 480&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;iPod&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;1.5 MB&lt;/p&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2526240.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/05/30/2526240.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/05/22/2513269.html</id><title type="text">IEEE printf specification</title><summary type="text">败家苹果参考直接引用http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html文档来说明格式化的使用，可该文档没有微软的MSDN说的清楚明确，看看下面MSDN给出的格式说明可以说明一切。%[flags][width][.perc] [F|N|h|l]type1.type 含义如下： d 有符号10进制整数 i 有符号10进制整数 o 有符号8进制整数 u 无符号10进制整数 x 无符号的16进制数字，并以小写abcdef表示 X 无符号的16进制数字，并以大写ABCDEF表示 F/f 浮点数 E/e ...</summary><published>2012-05-22T06:12:00Z</published><updated>2012-05-22T06:12:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/22/2513269.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/22/2513269.html"/><content type="html">&lt;p&gt;败家苹果参考直接引用&lt;a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html"&gt;http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html&lt;/a&gt;&amp;nbsp;文档来说明格式化的使用，可该文档没有微软的MSDN说的清楚明确，看看下面MSDN给出的格式说明可以说明一切。&lt;/p&gt;&lt;p&gt;%[flags][width][.perc] [F|N|h|l]type&lt;/p&gt;&lt;p&gt;1.type 含义如下：&lt;/p&gt;&lt;p&gt;d 有符号10进制整数&lt;/p&gt;&lt;p&gt;i 有符号10进制整数&lt;/p&gt;&lt;p&gt;o 有符号8进制整数&lt;/p&gt;&lt;p&gt;u 无符号10进制整数&lt;/p&gt;&lt;p&gt;x 无符号的16进制数字，并以小写abcdef表示&lt;/p&gt;&lt;p&gt;X 无符号的16进制数字，并以大写ABCDEF表示&lt;/p&gt;&lt;p&gt;F/f 浮点数&lt;/p&gt;&lt;p&gt;E/e 用科学表示格式的浮点数&lt;/p&gt;&lt;p&gt;g 使用%f和%e表示中的总的位数表示最短的来表示浮点数 G 同g格式，但表示为指数&lt;/p&gt;&lt;p&gt;c 单个字符&lt;/p&gt;&lt;p&gt;s 字符串&lt;/p&gt;&lt;p&gt;% 显示百分号本身&lt;/p&gt;&lt;p&gt;p 显示一个指针，near指针表示为：XXXX&lt;/p&gt;&lt;p&gt;far 指针表示为：XXXX：YYYY&lt;/p&gt;&lt;p&gt;n 相连参量应是一个指针，其中存放已写字符的个数&lt;/p&gt;&lt;p&gt;2.flags 规定输出格式，取值和含义如下：&lt;/p&gt;&lt;p&gt;无 右对齐，左边填充0和空格&lt;/p&gt;&lt;p&gt;- 左对齐，右边填充空格&lt;/p&gt;&lt;p&gt;+ 在数字前增加符号 + 或 -&lt;/p&gt;&lt;p&gt;一个空格 只对负数显示符号&lt;/p&gt;&lt;p&gt;# 当type=c,s,d,i,u时没有影响&lt;/p&gt;&lt;p&gt;type=o,x,X时，分别在数值前增加'0',"0x","0X"&lt;/p&gt;&lt;p&gt;type=e,E,f时，总是使用小数点&lt;/p&gt;&lt;p&gt;type=g,G时，除了数值为0外总是显示小数点&lt;/p&gt;&lt;p&gt;3.width 用于控制显示数值的宽度，取值和含义如下n(n=1,2,3...) 宽度至少为n位，不够以空格填充0n(n=1,2,3...) 宽度至少为n位，不够左边以0填充 * 格式列表中&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;4.prec 用于控制小数点后面的位数，取值和含义如下：&lt;/p&gt;&lt;p&gt;无 按缺省精度显示&lt;/p&gt;&lt;p&gt;0 当type=d,i,o,u,x时，没有影响&lt;/p&gt;&lt;p&gt;type=e,E,f时，不显示小数点&lt;/p&gt;&lt;p&gt;n(n=1,2,3...) 当type=e,E,f时表示的最大小数位数&lt;/p&gt;&lt;p&gt;type=其他，表示显示的最大宽度 .*格式列表中&lt;/p&gt;&lt;p&gt;5.F|N|h|l 表示指针是否是远指针或整数是否是长整数&lt;/p&gt;&lt;p&gt;F 远指针&lt;/p&gt;&lt;p&gt;n 近指针&lt;/p&gt;&lt;p&gt;h短整数或单精度浮点数&lt;/p&gt;&lt;p&gt;l 长整数或双精度浮点数&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;strong&gt;再来看看官方网站如何说的,明显没有上面的直观。&lt;/strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The&amp;nbsp;&lt;em&gt;format&lt;/em&gt;&amp;nbsp;can contain either numbered argument conversion specifications (that is,&amp;nbsp;&lt;tt&gt;"&lt;span style="color: #0000ff;"&gt;%&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #0000ff;"&gt;&lt;em&gt;n&lt;/em&gt;&lt;/span&gt;&lt;tt&gt;&lt;span style="color: #0000ff;"&gt;$&lt;/span&gt;"&lt;/tt&gt;&amp;nbsp;and&amp;nbsp;&lt;tt&gt;"&lt;span style="color: #0000ff;"&gt;*&lt;/span&gt;&lt;/tt&gt;&lt;span style="color: #0000ff;"&gt;&lt;em&gt;m&lt;/em&gt;&lt;/span&gt;&lt;tt&gt;&lt;span style="color: #0000ff;"&gt;$&lt;/span&gt;"&lt;/tt&gt;), or unnumbered argument conversion specifications (that is,&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&lt;tt&gt;%&lt;/tt&gt;&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&lt;tt&gt;*&lt;/tt&gt;&lt;/span&gt;&amp;nbsp;), but not both. The only exception to this is that&amp;nbsp;&lt;tt&gt;%%&lt;/tt&gt;&amp;nbsp;can be mixed with the&amp;nbsp;&lt;tt&gt;"%&lt;/tt&gt;&lt;em&gt;n&lt;/em&gt;&lt;tt&gt;$"&lt;/tt&gt;&amp;nbsp;form. The results of mixing numbered and unnumbered argument specifications in a&amp;nbsp;&lt;em&gt;format&lt;/em&gt;&amp;nbsp;string are undefined. When numbered argument specifications are used, specifying the&amp;nbsp;&lt;em&gt;N&lt;/em&gt;th argument requires that all the leading arguments, from the first to the (&lt;em&gt;N-1&lt;/em&gt;)th, are specified in the format string.&lt;/p&gt;&lt;p&gt;In format strings containing the&amp;nbsp;&lt;tt&gt;"%&lt;/tt&gt;&lt;em&gt;n&lt;/em&gt;&lt;tt&gt;$"&lt;/tt&gt;&amp;nbsp;form of conversion specification, numbered arguments in the argument list can be referenced from the format string as many times as required.&amp;nbsp;&lt;img src="http://pubs.opengroup.org/onlinepubs/009695399/images/opt-end.gif" alt="[Option End]" border="0" /&gt;&lt;/p&gt;&lt;p&gt;In format strings containing the&amp;nbsp;&lt;tt&gt;%&lt;/tt&gt;&amp;nbsp;form of conversion specification, each conversion specification uses the first unused argument in the argument list.&lt;/p&gt;&lt;p&gt;&lt;sup&gt;[&lt;a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html"&gt;CX&lt;/a&gt;]&lt;/sup&gt;&amp;nbsp;&lt;img src="http://pubs.opengroup.org/onlinepubs/009695399/images/opt-start.gif" alt="[Option Start]" border="0" /&gt;&amp;nbsp;All forms of the&amp;nbsp;&lt;em&gt;fprintf&lt;/em&gt;() functions allow for the insertion of a language-dependent radix character in the output string. The radix character is defined in the program's locale (category&amp;nbsp;&lt;em&gt;LC_NUMERIC ).&lt;/em&gt;&amp;nbsp;In the POSIX locale, or in a locale where the radix character is not defined, the radix character shall default to a period (&amp;nbsp;&lt;tt&gt;'.'&lt;/tt&gt;&amp;nbsp;).&amp;nbsp;&lt;img src="http://pubs.opengroup.org/onlinepubs/009695399/images/opt-end.gif" alt="[Option End]" border="0" /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Each conversion specification is introduced by the&amp;nbsp;&lt;tt&gt;'%'&lt;/tt&gt;&amp;nbsp;character&amp;nbsp;&lt;sup&gt;[&lt;a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html"&gt;XSI&lt;/a&gt;]&lt;/sup&gt;&amp;nbsp;&lt;img src="http://pubs.opengroup.org/onlinepubs/009695399/images/opt-start.gif" alt="[Option Start]" border="0" /&gt;&amp;nbsp;&amp;nbsp;or by the character sequence&amp;nbsp;&lt;tt&gt;"%&lt;/tt&gt;&lt;em&gt;n&lt;/em&gt;&lt;tt&gt;$"&lt;/tt&gt;,&amp;nbsp;&lt;img src="http://pubs.opengroup.org/onlinepubs/009695399/images/opt-end.gif" alt="[Option End]" border="0" /&gt;&amp;nbsp;after which the following appear in sequence:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;Zero or more&amp;nbsp;&lt;em&gt;flags&lt;/em&gt;&amp;nbsp;(in any order), which modify the meaning of the conversion specification.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;An optional minimum&amp;nbsp;&lt;em&gt;field width&lt;/em&gt;. If the converted value has fewer bytes than the field width, it shall be padded with spaces by default on the left; it shall be padded on the right if the left-adjustment flag (&amp;nbsp;&lt;tt&gt;'-'&lt;/tt&gt;&amp;nbsp;), described below, is given to the field width. The field width takes the form of an asterisk (&amp;nbsp;&lt;tt&gt;'*'&lt;/tt&gt;&amp;nbsp;), described below, or a decimal integer.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;An optional&amp;nbsp;&lt;em&gt;precision&lt;/em&gt;&amp;nbsp;that gives the minimum number of digits to appear for the&amp;nbsp;&lt;tt&gt;d&lt;/tt&gt;,&amp;nbsp;&lt;tt&gt;i&lt;/tt&gt;,&amp;nbsp;&lt;tt&gt;o&lt;/tt&gt;,&amp;nbsp;&lt;tt&gt;u&lt;/tt&gt;,&amp;nbsp;&lt;tt&gt;x&lt;/tt&gt;, and&amp;nbsp;&lt;tt&gt;X&lt;/tt&gt;&amp;nbsp;conversion specifiers; the number of digits to appear after the radix character for the&amp;nbsp;&lt;tt&gt;a&lt;/tt&gt;,&amp;nbsp;&lt;tt&gt;A&lt;/tt&gt;,&amp;nbsp;&lt;tt&gt;e&lt;/tt&gt;,&amp;nbsp;&lt;tt&gt;E&lt;/tt&gt;,&amp;nbsp;&lt;tt&gt;f&lt;/tt&gt;, and&amp;nbsp;&lt;tt&gt;F&lt;/tt&gt;&amp;nbsp;conversion specifiers; the maximum number of significant digits for the&amp;nbsp;&lt;tt&gt;g&lt;/tt&gt;&amp;nbsp;and&amp;nbsp;&lt;tt&gt;G&lt;/tt&gt;&amp;nbsp;conversion specifiers; or the maximum number of bytes to be printed from a string in the&amp;nbsp;&lt;tt&gt;s&lt;/tt&gt;&amp;nbsp;&lt;sup&gt;[&lt;a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html"&gt;XSI&lt;/a&gt;]&lt;/sup&gt;&amp;nbsp;&lt;img src="http://pubs.opengroup.org/onlinepubs/009695399/images/opt-start.gif" alt="[Option Start]" border="0" /&gt;&amp;nbsp;&amp;nbsp;and&amp;nbsp;&lt;tt&gt;S&lt;/tt&gt;&amp;nbsp;&lt;img src="http://pubs.opengroup.org/onlinepubs/009695399/images/opt-end.gif" alt="[Option End]" border="0" /&gt;&amp;nbsp;&amp;nbsp;conversion specifiers. The precision takes the form of a period (&amp;nbsp;&lt;tt&gt;'.'&lt;/tt&gt;&amp;nbsp;) followed either by an asterisk (&amp;nbsp;&lt;tt&gt;'*'&lt;/tt&gt;&amp;nbsp;), described below, or an optional decimal digit string, where a null digit string is treated as zero. If a precision appears with any other conversion specifier, the behavior is undefined.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;An optional length modifier that specifies the size of the argument.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;A&amp;nbsp;&lt;em&gt;conversion specifier&lt;/em&gt;&amp;nbsp;character that indicates the type of conversion to be applied.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;A field width, or precision, or both, may be indicated by an asterisk (&amp;nbsp;&lt;tt&gt;'*'&lt;/tt&gt;&amp;nbsp;). In this case an argument of type&amp;nbsp;&lt;strong&gt;int&lt;/strong&gt;&amp;nbsp;supplies the field width or precision. Applications shall ensure that arguments specifying field width, or precision, or both appear in that order before the argument, if any, to be converted. A negative field width is taken as a&amp;nbsp;&lt;tt&gt;'-'&lt;/tt&gt;&amp;nbsp;flag followed by a positive field width. A negative precision is taken as if the precision were omitted.&amp;nbsp;&lt;sup&gt;[&lt;a href="http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html"&gt;XSI&lt;/a&gt;]&lt;/sup&gt;&amp;nbsp;&lt;img src="http://pubs.opengroup.org/onlinepubs/009695399/images/opt-start.gif" alt="[Option Start]" border="0" /&gt;&amp;nbsp;&amp;nbsp;In format strings containing the&amp;nbsp;&lt;tt&gt;"%&lt;/tt&gt;&lt;em&gt;n&lt;/em&gt;&lt;tt&gt;$"&lt;/tt&gt;&amp;nbsp;form of a conversion specification, a field width or precision may be indicated by the sequence&amp;nbsp;&lt;tt&gt;"*&lt;/tt&gt;&lt;em&gt;m&lt;/em&gt;&lt;tt&gt;$"&lt;/tt&gt;, where&amp;nbsp;&lt;em&gt;m&lt;/em&gt;&amp;nbsp;is a decimal integer in the range [1,{NL_ARGMAX}] giving the position in the argument list (after the&amp;nbsp;&lt;em&gt;format&lt;/em&gt;&amp;nbsp;argument) of an integer argument containing the field width or precision, &lt;strong&gt;for example:&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&lt;div&gt;&lt;p&gt;&lt;span style="color: #ff0000;"&gt;&lt;em&gt;&lt;strong&gt;&lt;span style="color: #3366ff;"&gt;NSLog(@"%1$d05d:%2$.*3$f:%4$.*1$d", 2, 0.55557&lt;span style="color: #ff0000;"&gt;56&lt;/span&gt;, 6, 3);&lt;/span&gt; &lt;/strong&gt;&lt;/em&gt;// 0000&lt;strong&gt;2:0.5555&lt;span style="color: #0000ff;"&gt;76&lt;/span&gt;:03&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2513269.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/05/22/2513269.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/05/17/2505753.html</id><title type="text">Core &amp;#39;s Framework</title><summary type="text">Core Graphics FrameworkThe Core Graphics framework (CoreGraphics.framework) contains the interfaces for the Quartz 2D drawing API.Quartzis the same advanced, vector-based drawing engine that is used in Mac OS X. It provides support for path-based drawing, anti-aliased rendering, gradients, images, c</summary><published>2012-05-17T01:33:00Z</published><updated>2012-05-17T01:33:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/17/2505753.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/17/2505753.html"/><content type="html">&lt;h3 class="jump"&gt;Core Graphics Framework&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The Core Graphics framework (&lt;code&gt;CoreGraphics.framework&lt;/code&gt;) contains the interfaces for the Quartz 2D drawing API.&amp;nbsp;&lt;strong&gt;Quartz&lt;/strong&gt;&amp;nbsp;is the same advanced, vector-based drawing engine that is used in Mac OS X. It provides support for path-based drawing, anti-aliased rendering, gradients, images, colors, coordinate-space transformations, and PDF document creation, display, and parsing. Although the API is C based, it uses object-based abstractions to represent fundamental drawing objects, making it easy to store and reuse your graphics content.&lt;/p&gt;&lt;p&gt;Quartz 2D is an advanced, two-dimensional drawing engine available for iOS application development and to all Mac OS X application environments outside of the kernel. Quartz 2D provides low-level, lightweight 2D rendering with unmatched output fidelity regardless of display or printing device. Quartz 2D is resolution- and device-independent; you don&amp;rsquo;t need to think about the final destination when you use the Quartz 2D application programming interface (API) for drawing.&lt;/p&gt;&lt;p&gt;The Quartz 2D API is easy to use and provides access to powerful features such as transparency layers, path-based drawing, offscreen rendering, advanced color management, anti-aliased rendering, and PDF document creation, display, and parsing.&lt;/p&gt;&lt;p&gt;The Quartz 2D API is part of the Core Graphics framework, so you may see Quartz referred to as Core Graphics or, simply, CG.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h3 id="pageTitle"&gt;Quartz Core Framework&lt;/strong&gt;&lt;/p&gt;&lt;div class="importantbox clear"&gt;&lt;p&gt;The Quartz Core framework (&lt;code&gt;QuartzCore.framework&lt;/code&gt;) contains the Core Animation interfaces.&amp;nbsp;&lt;strong&gt;Core Animation&lt;/strong&gt;&amp;nbsp;is an advanced animation and compositing technology that uses an optimized rendering path to implement complex animations and visual effects. It provides a high-level Objective-C interface for configuring animations and effects that are then rendered in hardware for performance. Core Animation is integrated into many parts of iOS, including UIKit classes such as&amp;nbsp;&lt;code&gt;UIView&lt;/code&gt;, providing animations for many standard system behaviors. You can also use the Objective-C interface in this framework to create custom animations.&lt;/p&gt;&lt;h4 class="jump"&gt;The Quartz Core framework (&lt;code&gt;QuartzCore.framework&lt;/code&gt;) implements two important system technologies for graphics and imaging, Core Animation and Core Image.&lt;/strong&gt;&lt;/p&gt;&lt;h4 class="jump" style="margin-left: 30px;"&gt;Core Animation&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Core Animation is a set of Objective-C classes for doing sophisticated 2D rendering and animation. Using Core Animation, you can create everything from basic window content to carousel&amp;ndash;style user interfaces (such as Front Row&amp;rsquo;s), and achieve respectable animation performance without having to tune your code using OpenGL or other low-level drawing routines. This performance is achieved using server-side content caching, which restricts the compositing operations performed by the server to only those parts of a view or window whose contents actually change.&lt;/p&gt;&lt;p&gt;At the heart of the Core Animation programming model are layer objects, which are similar in many ways to Cocoa views. As with views, you can arrange layers in hierarchies, change their size and position, and tell them to draw themselves. Unlike views, layers do not support event-handling, accessibility, or drag and drop.&lt;/p&gt;&lt;p&gt;You can manipulate the layout of layers in more ways than the layout of traditional Cocoa views. In addition to positioning layers using a layout manager, you can apply 3D transforms to layers to rotate, scale, skew, or translate them in relation to their parent layer. In Mac OS X v10.7 and later, you can create a layer tree in one process and display it in another.&lt;/p&gt;&lt;p&gt;Layer content can be animated implicitly or explicitly depending on the actions you take. Modifying specific properties of a layer, such as its geometry, visual attributes, or children, typically triggers an implicit animation to transition from the old state to the new state of the property. For example, adding a child layer triggers an animation that causes the child layer to fade gradually into view. You can also trigger animations explicitly in a layer by modifying its transformation matrix.&lt;/p&gt;&lt;p&gt;You can manipulate layers independent of, or in conjunction with, the views and windows of your application. Cocoa applications can take advantage of the Core Animation&amp;rsquo;s integration with the&amp;nbsp;&lt;code&gt;NSView&lt;/code&gt;&amp;nbsp;class to add animation effects to windows. Layers can also support the following types of content:&lt;/p&gt;&lt;ul class="ul"&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li class="li"&gt;&lt;p&gt;Quartz and Cocoa drawing content&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;OpenGL content&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Quartz Composer compositions&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Core Image filter effects&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;For information about Core Animation, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Conceptual/Animation_Overview/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004952" target="_self"&gt;Animation Overview&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;h4 style="margin-left: 30px;"&gt;Core Image&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Core Image extends the basic graphics capabilities of the system to provide a framework for implementing complex visual behaviors in your application. Core Image uses GPU-based acceleration and 32-bit floating-point support to provide fast image processing and pixel-level accurate content. Its plug-in&amp;ndash;based architecture lets you expand the capabilities of Core Image through the creation of image units, which implement the desired visual effects.&lt;/p&gt;&lt;p&gt;Core Image includes built-in image units that allow you to:&lt;/p&gt;&lt;ul class="ul"&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li class="li"&gt;&lt;p&gt;Crop, composite, blur, and sharpen images&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Correct color, including perform white-point adjustments&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Apply color effects, such as sepia tone&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Warp the geometry of an image by applying an affine transform or a displacement effect&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Generate color, checkerboard patterns, Gaussian gradients, and other pattern images&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Add transition effects to images or video&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Provide real-time control, such as color adjustment and support for sports mode, vivid mode, and other video modes&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Apply linear lighting effects, such as spotlight effects&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;You can use both the built-in and custom image units in your application to implement special effects and perform other types of image manipulations. Beginning in Mac OS X v10.7, Core Image supports face detection; this feature detects faces in an image, yielding for each found face its bounds within the image and eye and mouth positions.&lt;/p&gt;&lt;p&gt;For information about how to use Core Image or how to write custom image units, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_intro/ci_intro.html#//apple_ref/doc/uid/TP30001185" target="_self"&gt;Core Image Programming Guide&lt;/a&gt;&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Reference/CoreImagingRef/_index.html#//apple_ref/doc/uid/TP40001171" target="_self"&gt;Core Image Reference Collection&lt;/a&gt;&lt;/em&gt;. For information about the built-in filters in Core Image, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/uid/TP40004346" target="_self"&gt;Core Image Filter Reference&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h3 id="pageTitle" style="margin-left: 30px;"&gt;Introduction to Core Image Programming Guide&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Core Image is an image processing technology built into Mac OS X v10.4 and iOS 5.0 that leverages programmable graphics hardware whenever possible to provide near real-time processing. The Core Image application programming interface (API) provides access to built-in image filters for both video and still images and provides support for creating custom filters.&lt;/p&gt;&lt;p&gt;Important&amp;nbsp;Although this document is included in the reference library, it has not been updated in detail for iOS 5.0. A forthcoming revision will detail the differences in Core Image on iOS. In particular, the key difference is that Core Image on iOS does not include the ability to create custom image filters.To use Core Image in Xcode, you need to import the&amp;nbsp;&lt;strong&gt;Quartz Core framework&lt;/strong&gt;.&lt;/p&gt;&lt;div class="importantbox clear" style="margin-left: 30px;"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 class="jump"&gt;&lt;span style="color: #ff0000;"&gt;&lt;strong&gt;Quartz&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The Quartz umbrella framework includes the following subframeworks. You should not link directly with any of the subframeworks; instead link with (and import)&amp;nbsp;&lt;code&gt;Quartz.framework&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;&lt;a title="Image Kit" name="//apple_ref/doc/uid/TP40001067-CH273-SW9"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h4 class="jump" style="margin-left: 30px;"&gt;Image Kit&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The Image Kit framework is an Objective-C framework that makes it easy to incorporate powerful imaging services into your applications. This framework takes advantage of features in Quartz, Core Image, OpenGL, and Core Animation to provide an advanced and highly optimized development path for implementing the following features:&lt;/p&gt;&lt;ul class="ul"&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li class="li"&gt;&lt;p&gt;Displaying images&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Rotating, cropping, and performing other image-editing operations&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Browsing for images&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Taking pictures using the built-in picture taker panel&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Displaying slideshows&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Browsing for Core Image filters&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Displaying custom views for Core Image filters&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;For more information on how to use Image Kit, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Conceptual/ImageKitProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004907" target="_self"&gt;Image Kit Programming Guide&lt;/a&gt;&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Reference/ImageKitReferenceCollection/_index.html#//apple_ref/doc/uid/TP40004664" target="_self"&gt;Image Kit Reference Collection&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;&lt;a title="PDF Kit" name="//apple_ref/doc/uid/TP40001067-CH273-SW12"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h4 class="jump" style="margin-left: 30px;"&gt;PDF Kit&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;PDF Kit is a Cocoa framework for managing and displaying PDF content directly from your application&amp;rsquo;s windows and dialogs. You can embed a&amp;nbsp;&lt;code&gt;PDFView&lt;/code&gt;&amp;nbsp;object in your window and give it a PDF file to display. The PDF view handles the rendering of the PDF content, handles copy-and-paste operations, and provides controls for navigating and setting the zoom level. Other classes let you get the number of pages in a PDF file, find text, manage selections, add annotations, and specify the behavior of some graphical elements, among other actions.&lt;/p&gt;&lt;p&gt;For more information on PDF Kit, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Conceptual/PDFKitGuide/PDFKit_Prog_Intro/PDFKit_Prog_Intro.html#//apple_ref/doc/uid/TP40001863" target="_self"&gt;PDF Kit Programming Guide&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;&lt;a title="Quartz Composer" name="//apple_ref/doc/uid/TP40001067-CH273-SW28"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h4 class="jump" style="margin-left: 30px;"&gt;Quartz Composer&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The Quartz Composer framework (&lt;code&gt;QuartComposer.framework&lt;/code&gt;) provides programmatic support for dealing with Quartz Composer compositions. It enables applications to load, play, and control compositions, including those in Core Animation layers.&lt;/p&gt;&lt;p&gt;For more information, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Conceptual/QuartzComposer/qc_intro/qc_intro.html#//apple_ref/doc/uid/TP40001357" target="_self"&gt;Quartz Composer Programming Guide&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;&lt;a title="Quick Look UI" name="//apple_ref/doc/uid/TP40001067-CH273-SW31"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h4 class="jump" style="margin-left: 30px;"&gt;Quick Look UI&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The Quick Look UI framework (&lt;code&gt;QuickLookUI.framework&lt;/code&gt;), introduced in Mac OS X v10.6, defines an interface for implementing a Quick Look preview panel, which displays the preview of a list of items. In Mac OS X v10.7, the framework added the capability for embedding a preview inside a view.&lt;/p&gt;&lt;p&gt;For an example of an application that implements Quick Look preview panels, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/samplecode/QuickLookDownloader/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009082" target="_self"&gt;QuickLookDownloader&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;&lt;a title="Quartz Core" name="//apple_ref/doc/uid/TP40001067-CH273-SW7"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 class="jump" style="margin-left: 30px;"&gt;Quartz Core&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The Quartz Core framework (&lt;code&gt;QuartzCore.framework&lt;/code&gt;) implements two important system technologies for graphics and imaging, Core Animation and Core Image.&lt;/p&gt;&lt;p&gt;&lt;a title="Core Animation" name="//apple_ref/doc/uid/TP40001067-CH273-SW29"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h4 class="jump" style="margin-left: 30px;"&gt;Core Animation&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Core Animation is a set of Objective-C classes for doing sophisticated 2D rendering and animation. Using Core Animation, you can create everything from basic window content to carousel&amp;ndash;style user interfaces (such as Front Row&amp;rsquo;s), and achieve respectable animation performance without having to tune your code using OpenGL or other low-level drawing routines. This performance is achieved using server-side content caching, which restricts the compositing operations performed by the server to only those parts of a view or window whose contents actually change.&lt;/p&gt;&lt;p&gt;At the heart of the Core Animation programming model are layer objects, which are similar in many ways to Cocoa views. As with views, you can arrange layers in hierarchies, change their size and position, and tell them to draw themselves. Unlike views, layers do not support event-handling, accessibility, or drag and drop.&lt;/p&gt;&lt;p&gt;You can manipulate the layout of layers in more ways than the layout of traditional Cocoa views. In addition to positioning layers using a layout manager, you can apply 3D transforms to layers to rotate, scale, skew, or translate them in relation to their parent layer. In Mac OS X v10.7 and later, you can create a layer tree in one process and display it in another.&lt;/p&gt;&lt;p&gt;Layer content can be animated implicitly or explicitly depending on the actions you take. Modifying specific properties of a layer, such as its geometry, visual attributes, or children, typically triggers an implicit animation to transition from the old state to the new state of the property. For example, adding a child layer triggers an animation that causes the child layer to fade gradually into view. You can also trigger animations explicitly in a layer by modifying its transformation matrix.&lt;/p&gt;&lt;p&gt;You can manipulate layers independent of, or in conjunction with, the views and windows of your application. Cocoa applications can take advantage of the Core Animation&amp;rsquo;s integration with the&amp;nbsp;&lt;code&gt;NSView&lt;/code&gt;&amp;nbsp;class to add animation effects to windows. Layers can also support the following types of content:&lt;/p&gt;&lt;ul class="ul"&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li class="li"&gt;&lt;p&gt;Quartz and Cocoa drawing content&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;OpenGL content&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Quartz Composer compositions&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Core Image filter effects&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;For information about Core Animation, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Conceptual/Animation_Overview/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004952" target="_self"&gt;Animation Overview&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;&lt;a title="Core Image" name="//apple_ref/doc/uid/TP40001067-CH273-SW30"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h4 class="jump" style="margin-left: 30px;"&gt;Core Image&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Core Image extends the basic graphics capabilities of the system to provide a framework for implementing complex visual behaviors in your application. Core Image uses GPU-based acceleration and 32-bit floating-point support to provide fast image processing and pixel-level accurate content. Its plug-in&amp;ndash;based architecture lets you expand the capabilities of Core Image through the creation of image units, which implement the desired visual effects.&lt;/p&gt;&lt;p&gt;Core Image includes built-in image units that allow you to:&lt;/p&gt;&lt;ul class="ul"&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li style="list-style-type: none;"&gt;&lt;ul&gt;&lt;li class="li"&gt;&lt;p&gt;Crop, composite, blur, and sharpen images&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Correct color, including perform white-point adjustments&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Apply color effects, such as sepia tone&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Warp the geometry of an image by applying an affine transform or a displacement effect&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Generate color, checkerboard patterns, Gaussian gradients, and other pattern images&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Add transition effects to images or video&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Provide real-time control, such as color adjustment and support for sports mode, vivid mode, and other video modes&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;Apply linear lighting effects, such as spotlight effects&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;You can use both the built-in and custom image units in your application to implement special effects and perform other types of image manipulations. Beginning in Mac OS X v10.7, Core Image supports face detection; this feature detects faces in an image, yielding for each found face its bounds within the image and eye and mouth positions.&lt;/p&gt;&lt;p&gt;For information about how to use Core Image or how to write custom image units, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_intro/ci_intro.html#//apple_ref/doc/uid/TP30001185" target="_self"&gt;Core Image Programming Guide&lt;/a&gt;&lt;/em&gt;&amp;nbsp;and&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Reference/CoreImagingRef/_index.html#//apple_ref/doc/uid/TP40001171" target="_self"&gt;Core Image Reference Collection&lt;/a&gt;&lt;/em&gt;. For information about the built-in filters in Core Image, see&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Reference/CoreImageFilterReference/Reference/reference.html#//apple_ref/doc/uid/TP40004346" target="_self"&gt;Core Image Filter Reference&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;&lt;a title="QuickTime Kit" name="//apple_ref/doc/uid/TP40001067-CH273-SW2"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h3 class="jump" style="margin-left: 30px;"&gt;QuickTime Kit&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The QuickTime Kit (&lt;code&gt;QTKit.framework&lt;/code&gt;), or QTKit, is an Objective-C framework for manipulating QuickTime-based media. This framework lets you incorporate movie playback, movie editing, export to standard media formats, and other QuickTime behaviors easily into your applications.&lt;/p&gt;&lt;div class="notebox"&gt;&lt;a title="Note" name="//apple_ref/doc/uid/TP40001067-CH273-SW20"&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2505753.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/05/17/2505753.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/05/03/2480296.html</id><title type="text">The Mac Application Environment</title><summary type="text">The Mac Application EnvironmentMac OS X incorporates the latest technologies for creating powerful and fun-to-use apps. But the technologies by themselves are not enough to make every app great. What sets an app apart from its peers is how it helps the user achieve some tangible goal. After all, use</summary><published>2012-05-03T03:09:00Z</published><updated>2012-05-03T03:09:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/03/2480296.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/03/2480296.html"/><content type="html">&lt;p&gt;The Mac Application Environment&lt;/p&gt;&lt;p&gt;&lt;span&gt;Mac OS X incorporates the latest technologies for creating powerful and fun-to-use apps. &lt;/span&gt;But the technologies by themselves are not enough to make every app great. What sets an app apart from its peers is how it helps the user achieve some tangible goal. &lt;span&gt;After all, users are not going to care what technologies an app uses, as long as it helps them do what they need to do. &lt;/span&gt;An app that gets in the user&amp;rsquo;s way is going to be forgotten, but one that makes work (or play) easier and more fun is going to be remembered.&lt;/p&gt;&lt;p&gt;An Environment Designed for Ease of Use&lt;/p&gt;&lt;p&gt;Mac OS X strives to provide an environment that is transparent to users and as easy to use as possible. By making hard tasks simple and getting out of the way, the system makes it easier for the user to be creative and spend less time worrying about the steps needed to make the computer work. Of course, simplifying tasks means your app has to do more of the work, but Mac OS You should consider providing your users with an immersive, full-screen experience by implementing a full-screen version of your user interface. The full-screen experience eliminates outside distractions and allows the user to focus on their content; see &lt;span&gt;&amp;ldquo;Implementing the Full-Screen Experience&amp;rdquo; &lt;/span&gt;(page 66).&lt;/p&gt;&lt;p&gt;Support trackpad gestures for appropriate actions in your app. Gestures provide simple shortcuts for common tasks and can be used to supplement existing controls and menu commands. Mac OS X provides automatic support for reporting gestures to your app through the normal event-handling mechanism; see &lt;em&gt;Cocoa Event-Handling Guide &lt;/em&gt;.&lt;/p&gt;&lt;p&gt;Consider minimizing or eliminating the user&amp;rsquo;s interactions with the raw file system. Rather than expose the entire file system to the user through the open and save panels, some apps, in the manner of iPhoto and iTunes, can provide a better user experience by presenting the user&amp;rsquo;s content in a simplified browser designed specifically for the app&amp;rsquo;s content. Mac OS X uses a well-defined file system structure that allows you to place and find files easily and includes many technologies for accessing those files; see &lt;span&gt;&amp;ldquo;The File System&amp;rdquo; &lt;/span&gt;(page 13).&lt;/p&gt;&lt;p&gt;A Sophisticated Graphics Environment&lt;/p&gt;&lt;p&gt;High-quality graphics and animation make your app look great and can convey a lot of information to the user. Animations in particular are a great way to provide feedback about changes to your user interface.&amp;nbsp;&lt;/p&gt;&lt;p&gt;Low-Level Details of the Runtime Environment&lt;/p&gt;&lt;p&gt;When you are ready to begin writing actual code, there are a lot of technologies available to make your life easier. Mac OS X supports all of the basic features such as memory management, file management, networking, and concurrency that you need to write your code. In some cases, though, Mac OS X also provides more sophisticated services (or specific coding conventions) that, when followed, can make writing your code even easier.&lt;/p&gt;&lt;p&gt;Based on UNIX&lt;/p&gt;&lt;p&gt;Mac OS X is powered by a 64-bit Mach kernel, which manages processor resources, memory, and other low-level behaviors. On top of the kernel sits a modified version of the Berkeley Software Distribution (BSD) operating system, which provides interfaces that apps can use to interact with the lower-level system. &lt;span&gt;This combination of Mach and BSD provides the following system-level support for your apps:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Preemptive multitasking&amp;mdash;All &lt;/strong&gt;processes share the CPU efficiently. The kernel schedules processes in a way that ensures they all receive the time they need to run. Even background apps continue to receive CPU time to execute ongoing tasks.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Protected memory&amp;mdash;Each &lt;/strong&gt;process runs in its own protected memory space, which prevents processes from accidentally interfering with each other. (Apps can share part of their memory space to implement fast interprocess communication but take responsibility for synchronizing and locking that memory appropriately.)&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Virtual memory&amp;mdash;64-bit &lt;/strong&gt;apps have a virtual address space of approximately 18 exabytes (18 billion billion bytes). (If you create a 32-bit app, the amount of virtual memory is only 4 GB.) When an app&amp;rsquo;s memory usage exceeds the amount of free physical memory, the system transparently writes pages to disk to make more room. Written out pages remain on disk until they are needed in memory again or the app exits.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Networking &lt;/strong&gt;and &lt;strong&gt;Bonjour&amp;mdash;Mac &lt;/strong&gt;OS X provides support for the standard networking protocols and services in use today. BSD sockets provide the low-level communication mechanism for apps, but higher-level interfaces also exist. Bonjour simplifies the user networking experience by providing a dynamic way to advertise and connect to network services over TCP/IP.&lt;/p&gt;&lt;p&gt;Concurrency and Threading&lt;/p&gt;&lt;p&gt;Each process starts off with a single thread of execution and can create more threads as needed. Although you can create threads directly using POSIX and other higher-level interfaces, for most types of work it is better to create them indirectly using &lt;span&gt;block objects &lt;/span&gt;with &lt;strong&gt;Grand Central Dispatch (GCD) &lt;/strong&gt;or &lt;strong&gt;operation objects, &lt;/strong&gt;a Cocoa concurrency technology implemented by the &lt;span&gt;NSOperation &lt;/span&gt;class.&lt;/p&gt;&lt;p&gt;GCD and operation objects are an alternative to raw threads that simplify or eliminate many of the problems normally associated with threaded programming, such as synchronization and locking. Specifically, they define an asynchronous programming model in which you specify only the work to be performed and the order in which you want it performed. The system then handles the tedious work required to schedule the necessary threads and execute your tasks as efficiently as possible on the current hardware. You should not use GCD or operations for work requiring time-sensitive data processing (such as audio or video playback), but you can use them for most other types of tasks.&lt;/p&gt;&lt;p&gt;For more information on using GCD and operation objects to implement concurrency in your apps, see &lt;em&gt;Concurrency Programming Guide &lt;/em&gt;.&lt;/p&gt;&lt;p&gt;The File System&lt;/p&gt;&lt;p&gt;The file system in Mac OS X is structured to provide a better experience for users. Rather than exposing the entire file system to the user, the Finder hides any files and directories that an average user should not need to use, such as the contents of low-level UNIX directories. &lt;span&gt;This is done to provide a simpler interface for the end user&lt;/span&gt; (and only in places like the Finder and the open and save panels). Apps can still access any files and directories for which they have valid permissions, regardless of whether they are hidden by the Finder.&lt;/p&gt;&lt;p&gt;When creating apps, you should understand and follow the conventions associated with the Mac OS X file system. &lt;span&gt;Knowing where to put files&lt;/span&gt; and how to get information out of the file system ensures a better user experience.&lt;/p&gt;&lt;p&gt;A Few Important App Directories&lt;/p&gt;&lt;p&gt;The Mac OS X file system is organized in a way that groups related files and data together in specific places. Every file in the file system has its place and apps need to know where to put the files they create. This is especially important if you are distributing your app through the App Store, which expects you to put your app&amp;rsquo;s data files in specific directories.&lt;/p&gt;&lt;p&gt;Table 1-1 lists the directories with which apps commonly interact. Directories preceded with a tilde (~) character indicate a path inside the home directory, which can be either the user&amp;rsquo;s home directory or the app&amp;rsquo;s container directory if the app is in a sandbox (as described in &lt;span&gt;&amp;ldquo;App Sandbox and XPC&amp;rdquo; &lt;/span&gt;(page 18)). Because the actual paths can differ based on the conditions, use the &lt;span&gt;URLsForDirectory:inDomains: &lt;/span&gt;method of the &lt;span&gt;NSFileManager &lt;/span&gt;class to retrieve the actual directory path. You can then add any custom directory and filename information to the returned URL object to complete the path.&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;strong&gt;Table 1-1 &lt;/strong&gt;&lt;/span&gt;Key directories for Mac OS X apps&lt;/p&gt;&lt;table cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Directory&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Applications directory&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This is the installation directory for your app &lt;span&gt;bundle. &lt;/span&gt;The path for the global Applications directory is &lt;span&gt;/Applications &lt;/span&gt;but each user directory may have a local applications directory containing user-specific apps. Regardless, you should not need to use this path directly. To access resources inside your application bundle, use an &lt;span&gt;NSBundle &lt;/span&gt;object instead.&lt;/p&gt;&lt;p&gt;For more information about the structure of your application bundle and how you locate resources, see &lt;span&gt;&amp;ldquo;The Mac OS X Application Bundle&amp;rdquo; &lt;/span&gt;(page 81).&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Home directory&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The configuration of your app determines the location of the home directory seen by your app:&lt;/p&gt;&lt;p&gt;For apps running in a sandbox in Mac OS X 10.7 and later, the home directory is the app&amp;rsquo;s container directory. For more information about the container directory, see &lt;span&gt;&amp;ldquo;The Keychain&amp;rdquo; &lt;/span&gt;(page 20).&lt;/p&gt;&lt;p&gt;For apps running outside of a sandbox (including those running in versions of Mac OS X before 10.7), the home directory is the user-specific subdirectory of &lt;span&gt;/Users &lt;/span&gt;that contains the user&amp;rsquo;s files.&lt;/p&gt;&lt;p&gt;To retrieve the path to the home directory, use the &lt;span&gt;NSHomeDirectory &lt;/span&gt;function.&lt;/p&gt;&lt;p&gt;●&lt;/p&gt;&lt;p&gt;●&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Library directory&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The Library directory is the top-level directory for storing private app-related data and preferences. There are several Library directories scattered throughout the system but you should always use the one located inside the current home directory.&lt;/p&gt;&lt;p&gt;Do not store files directly at the top-level of the Library directory. Instead, store them in one of the specific subdirectories described in this table.&lt;/p&gt;&lt;p&gt;In Mac OS X 10.7 and later, the Finder hides the Library directory in the user&amp;rsquo;s home folder by default. Therefore, you should never store files in this directory that you want the user to access.&lt;/p&gt;&lt;p&gt;To get the path to this directory use the &lt;span&gt;NSLibraryDirectory &lt;/span&gt;search path key with the &lt;span&gt;NSUserDomainMask &lt;/span&gt;domain.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;table cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Directory&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Application Support directory&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The Application Support directory is where your app stores any type of file that supports the app but is not required for the app to run, such as document templates or configuration files. The files should be app-specific but should never store user data. This directory is located inside the Library directory.&lt;/p&gt;&lt;p&gt;Never store files at the top level of this directory: Always put them in a subdirectory named for your app or company.&lt;/p&gt;&lt;p&gt;If the resources apply to all users on the system, such as document templates, place them in &lt;span&gt;/Library/Application Support. &lt;/span&gt;To get the path to this directory use the &lt;span&gt;NSApplicationSupportDirectory &lt;/span&gt;search path key with the &lt;span&gt;NSLocalDomainMask &lt;/span&gt;domain. If the resources are user-specific, such as workspace configuration files, place them in the current user&amp;rsquo;s &lt;span&gt;~/Library/Application Support &lt;/span&gt;directory. To get the path to this directory use the &lt;span&gt;NSApplicationSupportDirectory &lt;/span&gt;search path key with the &lt;span&gt;NSUserDomainMask &lt;/span&gt;domain.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Caches directory&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The Caches directory is where you store cache files and other temporary data that your app can re-create as needed. This directory is located inside the Library directory.&lt;/p&gt;&lt;p&gt;Never store files at the top level of this directory: Always put them in a subdirectory named for your app or company. Your app is responsible for cleaning out cache data files when they are no longer needed. The system does not delete files from this directory.&lt;/p&gt;&lt;p&gt;To get the path to this directory use the &lt;span&gt;NSCachesDirectory &lt;/span&gt;search path key with the &lt;span&gt;NSUserDomainMask &lt;/span&gt;domain.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Movies directory&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The Movies directory contains the user&amp;rsquo;s video files.&lt;/p&gt;&lt;p&gt;To get the path to this directory use the &lt;span&gt;NSMoviesDirectory &lt;/span&gt;search path key with the &lt;span&gt;NSUserDomainMask &lt;/span&gt;domain.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Music directory&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The Music directory contains the user&amp;rsquo;s music and audio files.&lt;/p&gt;&lt;p&gt;To get the path to this directory use the &lt;span&gt;NSMusicDirectory &lt;/span&gt;search path key with the &lt;span&gt;NSUserDomainMask &lt;/span&gt;domain.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Pictures directory&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The Pictures directory contains the user&amp;rsquo;s images and photos.&lt;/p&gt;&lt;p&gt;To get the path to this directory use the &lt;span&gt;NSPicturesDirectory &lt;/span&gt;search path key with the &lt;span&gt;NSUserDomainMask &lt;/span&gt;domain.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;img src="webkit-fake-url://F38834A7-0FA3-4CEF-969E-2F56E97180A4/page16image1664.png" alt="page16image1664.png" /&gt;&lt;/p&gt;&lt;table cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Directory&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Temporary directory&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The Temporary directory is where you store files that do not need to persist between launches of your app. You normally use this directory for scratch files or other types of short-lived data files that are not related to your app&amp;rsquo;s persistent data. This directory is typically hidden from the user.&lt;/p&gt;&lt;p&gt;Your app should remove files from this directory as soon as it is done with them. The system may also purge lingering files from this directory at system startup.&lt;/p&gt;&lt;p&gt;To get the path to this directory use the &lt;span&gt;NSTemporaryDirectory &lt;/span&gt;function.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;Listing 1-1 shows an example of how to retrieve the base path to the &lt;span&gt;Application Support &lt;/span&gt;directory and then append a custom app directory to it.&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;strong&gt;Listing 1-1 &lt;/strong&gt;&lt;/span&gt;Getting the path to the &lt;span&gt;Application Support &lt;/span&gt;directory&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;NSFileManager* fileManager = [NSFileManager defaultManager];&lt;/p&gt;&lt;p&gt;NSURL* appSupportDir = nil;&lt;/p&gt;&lt;p&gt;NSArray *urls = [fileManager URLsForDirectory:NSApplicationSupportDirectory&lt;/p&gt;&lt;p&gt;inDomains:NSUserDomainMask];&lt;/p&gt;&lt;p&gt;if ([paths count] &amp;gt; 0) {&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; appSupportDir = [[urls objectAtIndex:0]&lt;/p&gt;&lt;p&gt;URLByAppendingPathComponent:@"com.example.MyApp"];&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;For more information about how to access files in well known system directories, see &lt;em&gt;File System Programming Guide &lt;/em&gt;.&lt;/p&gt;&lt;p&gt;Coordinating File Access with Other Processes&lt;/p&gt;&lt;p&gt;In Mac OS X, other processes may have access to the same files that your app does. Therefore, when working with files, you should use the file coordination interfaces introduced in Mac OS X v10.7 to be notified when other processes (including the Finder) attempt to read or modify files your app is currently using. For example, coordinating file access is critical when your app &lt;span&gt;&lt;strong&gt;adopts&lt;/strong&gt;&lt;/span&gt; iCloud storage.&lt;/p&gt;&lt;p&gt;The file coordination APIs allow you to assert ownership over files and directories that your app cares about. Any time another process attempts to touch one of those items, your app is given a chance to respond. For example, when an app attempts to read the contents of a document your app is editing, you can write unsaved changes to disk before the other process is allowed to do its reading.&lt;/p&gt;&lt;p&gt;&lt;span&gt;Using iCloud document storage, for example, you must incorporate file coordination because multiple apps can access your document files in iCloud.&lt;/span&gt; The simplest way to incorporate file coordination into your app is to use the &lt;span&gt;NSDocument &lt;/span&gt;class, which handles all of the file-related management for you. See &lt;em&gt;Document-Based App Programming Guide for Mac &lt;/em&gt;.&lt;/p&gt;&lt;p&gt;On the other hand, if you're writing a library-style (or &amp;ldquo;shoebox&amp;rdquo;) app, you must use the file coordination interfaces directly, as described in &lt;em&gt;File System Programming Guide &lt;/em&gt;.&lt;/p&gt;&lt;p&gt;Interacting with the File System&lt;/p&gt;&lt;p&gt;Disks in Macintosh computers are formatted using the HFS+ file system by default. However, Macintosh computers can interact with disks that use other formats so you should never code specifically to any one file system. Table 1-2 lists some of the basic file system attributes you may need to consider in your app and how you should handle them.&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;strong&gt;Table 1-2 &lt;/strong&gt;&lt;/span&gt;Attributes for the Mac OS X file system&lt;/p&gt;&lt;p&gt;&lt;img src="webkit-fake-url://F38834A7-0FA3-4CEF-969E-2F56E97180A4/page17image9696.png" alt="page17image9696.png" /&gt;&lt;/p&gt;&lt;table cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Attribute&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Case sensitivity&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;The HFS+ file system is case-insensitive but also case-preserving. Therefore, when specifying filenames and directories in your code, it is best to assume case-sensitivity.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Path construction&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Construct paths using the methods of the &lt;span&gt;NSURL &lt;/span&gt;and &lt;span&gt;NSString &lt;/span&gt;classes. The &lt;span&gt;NSURL &lt;/span&gt;class is preferred for path construction because of its ability to specify not only paths in the local file system but paths to network resources.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;File attributes&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Many file-related attributes can be retrieved using the &lt;span&gt;getResourceValue: forKey:error: &lt;/span&gt;method of the &lt;span&gt;NSURL &lt;/span&gt;class. You can also use an &lt;span&gt;NSFileManager &lt;/span&gt;object to retrieve many file-related attributes.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;File permissions&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;File permissions are managed using access control lists (ACLs) and BSD permissions. The system uses ACLs &lt;span&gt;whenever possible&lt;/span&gt; to specify precise permissions for files and directories, but it falls back to using BSD permissions when no ACLs are specified.&lt;/p&gt;&lt;p&gt;By default, any files your app creates are owned by the current user and given appropriate permissions. Thus, your app should always be able to read and write files it creates explicitly. In addition, the app&amp;rsquo;s sandbox may allow it to access other files in specific situations. For more information about the sandbox, see &lt;span&gt;&amp;ldquo;App Sandbox and XPC&amp;rdquo; &lt;/span&gt;(page 18).&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Tracking file changes&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Apps that cannot use the File Coordination interfaces (see &lt;span&gt;&amp;ldquo;Coordinating File Access with Other Processes&amp;rdquo; &lt;/span&gt;(page 16)) to track changes to files and directories can use the FSEvents API instead. This API provides a lower-level interface for tracking file system interactions and is available in Mac OS X v10.5 and later.&lt;/p&gt;&lt;p&gt;For information on how to use the FSEvents API, see &lt;em&gt;File System Events Programming Guide &lt;/em&gt;.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Security&lt;/p&gt;&lt;p&gt;The security technologies in Mac OS X help you safeguard sensitive data created or managed by your app, and help minimize damage caused by successful attacks from hostile code. These technologies impact how your app interacts with system resources and the file system.&lt;/p&gt;&lt;p&gt;App Sandbox and XPC&lt;/p&gt;&lt;p&gt;You secure your app against attack from malware by following the practices recommended in &lt;em&gt;Secure Coding Guide &lt;/em&gt;. But an attacker needs only to find a single hole in your defenses, or in any of the frameworks and libraries that you link against, to gain control of your app along with all of its privileges.&lt;/p&gt;&lt;p&gt;Starting in Mac OS X v10.7, &lt;strong&gt;App Sandbox &lt;/strong&gt;provides a last line of defense against stolen, corrupted, or deleted user data if malicious code exploits your app. App Sandbox also minimizes the damage from coding errors. Its strategy is twofold:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;App Sandbox enables you to describe how your app interacts with the system. The system then grants your app the access it needs to get its job done, and no more. For your app to provide the highest level of damage containment, the best practice is to adopt the tightest sandbox possible.&amp;nbsp;&lt;/li&gt;&lt;li&gt;App Sandbox allows the user to transparently grant your app additional access by way of Open and Save dialogs, drag and drop, and other familiar user interactions.&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;You describe your app&amp;rsquo;s interaction with the system by way of setting entitlements in Xcode. An &lt;strong&gt;entitlement &lt;/strong&gt;is a key-value pair, defined in a &lt;span&gt;property list file, &lt;/span&gt;that confers a specific capability or security permission to a target. For example, there are entitlement keys to indicate that your app needs access to the camera, the network, and user data such as the Address Book. For details on all the entitlements available in Mac OS X, see &lt;em&gt;Entitlement Key Reference &lt;/em&gt;.&lt;/p&gt;&lt;p&gt;When you adopt App Sandbox, the system provides a special directory for use by your app&amp;mdash;and only by your app&amp;mdash;called a &lt;strong&gt;container. &lt;/strong&gt;Your app has unfettered read/write access to the container. All Mac OS X path-finding APIs, above the POSIX layer, are relative to the container instead of to the user&amp;rsquo;s home directory. Other sandboxed apps have no access to your app&amp;rsquo;s container, as described further in &lt;span&gt;&amp;ldquo;Code Signing&amp;rdquo; &lt;/span&gt;(page 19).&lt;/p&gt;&lt;p&gt;&lt;strong&gt;iOSNote &lt;/strong&gt;Becauseitisnotforuserdocuments,aMacOSXcontainerdiffersfromaniOScontainer which, in iOS, is the one and only location for user documents. As the sole local location for user documents, an iOS container is usually known simply as an app&amp;rsquo;s Documents directory.&lt;/p&gt;&lt;p&gt;In addition, an iOS container contains the app itself. This is not so in Mac OS X.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;iCloudNote &lt;/strong&gt;Apple&amp;rsquo;siCloudtechnology,asdescribedin&amp;ldquo;iCloudStorage&amp;rdquo;(page49),usesthename &amp;ldquo;container&amp;rdquo; as well. There is no functional connection between an iCloud container and an App Sandbox container.&lt;/p&gt;&lt;p&gt;Your sandboxed app can access paths outside of its container in the following three ways:&lt;/p&gt;&lt;p&gt;At the specific direction of the user&lt;br /&gt;By you configuring your app with entitlements for specific file-system locations, such as the Movies folder When a path is in any of certain directories that are world readable&lt;/p&gt;&lt;p&gt;The Mac OS X security technology that interacts with the user to expand your sandbox is called &lt;strong&gt;Powerbox. &lt;/strong&gt;Powerbox has no API. Your app uses Powerbox transparently when, for example, you use the &lt;span&gt;NSOpenPanel &lt;/span&gt;and &lt;span&gt;NSSavePanel &lt;/span&gt;classes, or when the user employs drag and drop with your app.&lt;/p&gt;&lt;p&gt;Some app operations are more likely to be targets of malicious exploitation. Examples are the parsing of data received over a network, and the decoding of video frames. By using XPC, you can improve the effectiveness of the damage containment offered by App Sandbox by separating such potentially dangerous activities into their own address spaces.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;XPC &lt;/strong&gt;is a Mac OS X interprocess communication technology that complements App Sandbox by enabling privilege separation. &lt;strong&gt;Privilege separation, &lt;/strong&gt;in turn, is a development strategy in which you divide an app into pieces according to the system resource access that each piece needs. The component pieces that you create are called &lt;em&gt;XPC services &lt;/em&gt;. For details on adopting XPC, see &lt;em&gt;Daemons and Services Programming Guide &lt;/em&gt;.&lt;/p&gt;&lt;p&gt;For a complete explanation of App Sandbox and how to use it, read &lt;em&gt;App Sandbox Design Guide &lt;/em&gt;. &lt;span&gt;Code Signing&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Mac OS X employs the security technology known as &lt;span&gt;code signing &lt;/span&gt;to allow you to certify that your app was indeed created by you. After an app is code signed, the system can detect any change to the app&amp;mdash;whether the change is introduced accidentally or by malicious code. Various security technologies, including App Sandbox and parental controls, depend on code signing.&lt;/p&gt;&lt;p&gt;In most cases, you can rely on Xcode&amp;rsquo;s automatic code signing, which requires only that you specify a code signing identity in the build settings for your project. The steps to take are described in &lt;span&gt;&amp;ldquo;Code Signing Your App&amp;rdquo; &lt;/span&gt;in &lt;em&gt;Tools Workflow Guide for Mac &lt;/em&gt;. If you need to incorporate code signing into an automated build system, or if you link your app against third-party frameworks, refer to the procedures described in &lt;em&gt;Code Signing Guide &lt;/em&gt;.&lt;/p&gt;&lt;p&gt;When you adopt App Sandbox, you must code sign your app. This is because entitlements (including the special entitlement that enables App Sandbox) are built into an app&amp;rsquo;s code signature.&lt;/p&gt;&lt;p&gt;Mac OS X enforces a tie between an app&amp;rsquo;s container and the app&amp;rsquo;s code signature. This important security feature ensures that no other sandboxed app can access your container. The mechanism works as follows: After the system creates a container for an app, each time an app with the same bundle ID launches, the system checks that the app&amp;rsquo;s code signature matches a code signature expected by the container. If the system detects a mismatch, it prevents the app from launching.&lt;/p&gt;&lt;p&gt;For a complete explanation of code signing in the context of App Sandbox, read &lt;span&gt;&amp;ldquo;App Sandbox in Depth&amp;rdquo; &lt;/span&gt;in &lt;em&gt;App Sandbox Design Guide &lt;/em&gt;.&lt;/p&gt;&lt;p&gt;The Keychain&lt;/p&gt;&lt;p&gt;A keychain is a secure, encrypted container for storing a user&amp;rsquo;s passwords and other secrets. It is designed to help a user manage their multiple logins, each with its own ID and password. You should always use keychain to store sensitive credentials for your app.&lt;/p&gt;&lt;p&gt;For more on the keychain, see &lt;span&gt;&amp;ldquo;Keychain Services Concepts&amp;rdquo; &lt;/span&gt;in &lt;em&gt;Keychain Services Programming Guide &lt;/em&gt;.&lt;/p&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2480296.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/05/03/2480296.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/05/02/2479121.html</id><title type="text">Animations</title><summary type="text">AnimationsBoth UIKit and Core Animation provide support for animations, but the level of support provided by each technology varies.In UIKit, animations are performed using UIView objects.Table 4-1Animatable UIView propertiesPropertyChanges you can makeframeModify this property to change the view’s </summary><published>2012-05-02T07:33:00Z</published><updated>2012-05-02T07:33:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/02/2479121.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/05/02/2479121.html"/><content type="html">&lt;p&gt;Animations&lt;/p&gt;&lt;p&gt;Both UIKit and Core Animation provide support for animations, but the level of support provided by each technology varies.&amp;nbsp;&lt;/p&gt;&lt;p&gt;In UIKit, animations are performed using &lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/cl/UIView"&gt;&lt;span&gt;UIView&lt;/span&gt;&lt;/a&gt; objects.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Table 4-1&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Animatable &lt;span&gt;UIView&lt;/span&gt; properties&lt;/p&gt;&lt;table cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&lt;strong&gt;Property&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;&lt;strong&gt;Changes you can make&lt;/strong&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/frame"&gt;frame&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;Modify this property to change the view&amp;rsquo;s size and position relative to its superview&amp;rsquo;s coordinate system. (If the &lt;span&gt;transform&lt;/span&gt; property does not contain the identity transform, modify the &lt;span&gt;bounds&lt;/span&gt; or &lt;span&gt;center&lt;/span&gt; properties instead.)&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/bounds"&gt;bounds&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;Modify this property to change the view&amp;rsquo;s size.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/center"&gt;center&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;Modify this property to change the view&amp;rsquo;s position relative to its superview&amp;rsquo;s coordinate system.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/transform"&gt;transform&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;Modify this property to scale, rotate, or translate the view relative to its center point. Transformations using this property are always performed in 2D space. (To perform 3D transformations, you must animate the view&amp;rsquo;s layer object using Core Animation.)&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/alpha"&gt;alpha&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;Modify this property to gradually change the transparency of the view.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/backgroundColor"&gt;backgroundColor&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;Modify this property to change the view&amp;rsquo;s background color.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/contentStretch"&gt;contentStretch&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td valign="middle"&gt;&lt;p&gt;Modify this property to change the way the view&amp;rsquo;s contents are stretched to fill the available space.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;In places where you want to perform more sophisticated animations, or animations not supported by the &lt;span&gt;UIView&lt;/span&gt; class, you can use Core Animation and the view&amp;rsquo;s underlying layer to create the animation. Because view and layer objects are intricately linked together, changes to a view&amp;rsquo;s layer affect the view itself. Using Core Animation, you can animate the following types of changes for your view&amp;rsquo;s layer:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The size and position of the layer&lt;/li&gt;&lt;li&gt;The center point used when performing transformations&lt;/li&gt;&lt;li&gt;Transformations to the layer or its sublayers in 3D space&lt;/li&gt;&lt;li&gt;The addition or removal of a layer from the layer hierarchy&lt;/li&gt;&lt;li&gt;The layer&amp;rsquo;s Z-order relative to other sibling layers&lt;/li&gt;&lt;li&gt;The layer&amp;rsquo;s shadow&lt;/li&gt;&lt;li&gt;The layer&amp;rsquo;s border (including whether the layer&amp;rsquo;s corners are rounded)&lt;/li&gt;&lt;li&gt;The portion of the layer that stretches during resizing operations&lt;/li&gt;&lt;li&gt;The layer&amp;rsquo;s opacity&lt;/li&gt;&lt;li&gt;The clipping behavior for sublayers that lie outside the layer&amp;rsquo;s bounds&lt;/li&gt;&lt;li&gt;The current contents of the layer&lt;/li&gt;&lt;li&gt;The rasterization behavior of the layer&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Animating View and Layer Changes Together&lt;/p&gt;&lt;p&gt;Applications can freely mix view-based and layer-based animation code as needed but the process for configuring your animation parameters depends on who owns the layer. Changing a view-owned layer is the same as changing the view itself, and any animations you apply to the layer&amp;rsquo;s properties respect the animation parameters of the current view-based animation block. The same is not true for layers that you create yourself. Custom layer objects ignore view-based animation block parameters and use the default Core Animation parameters instead.&lt;/p&gt;&lt;p&gt;If you want to customize the animation parameters for layers you create, you must use Core Animation directly. Typically, animating layers using Core Animation involves creating a &lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Reference/CABasicAnimation_class/Introduction/Introduction.html#//apple_ref/occ/cl/CABasicAnimation"&gt;&lt;span&gt;CABasicAnimation&lt;/span&gt;&lt;/a&gt; object or some other concrete subclass of &lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Reference/CAAnimation_class/Introduction/Introduction.html#//apple_ref/occ/cl/CAAnimation"&gt;&lt;span&gt;CAAnimation&lt;/span&gt;&lt;/a&gt;. You then add that animation to the corresponding layer. You can apply the animation from either inside or outside a view-based animation block.&lt;/p&gt;&lt;p&gt;Listing 4-9 shows an animation that modifies a view and a custom layer at the same time. The view in this example contains a custom &lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/cl/CALayer"&gt;&lt;span&gt;CALayer&lt;/span&gt;&lt;/a&gt; object at the center of its bounds. The animation rotates the view counter clockwise while rotating the layer clockwise. Because the rotations are in opposite directions, the layer maintains its original orientation relative to the screen and does not appear to rotate significantly. However, the view beneath that layer spins 360 degrees and returns to its original orientation. This example is presented primarily to demonstrate how you can mix view and layer animations. This type of mixing should not be used in situations where precise timing is needed.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Listing 4-9&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Mixing view and layer animations&lt;/p&gt;&lt;table cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;[UIView animateWithDuration:1.0&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; delay:0.0&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; options: UIViewAnimationOptionCurveLinear&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; animations:^{&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Animate the first half of the view rotation.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CGAffineTransform&amp;nbsp; xform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-180));&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; backingView.transform = xform;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Rotate the embedded CALayer in the opposite direction.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CABasicAnimation*&amp;nbsp; &amp;nbsp; layerAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layerAnimation.duration = 2.0;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layerAnimation.beginTime = 0; //CACurrentMediaTime() + 1;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layerAnimation.valueFunction = [CAValueFunction functionWithName:kCAValueFunctionRotateZ];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layerAnimation.timingFunction = [CAMediaTimingFunction&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; functionWithName:kCAMediaTimingFunctionLinear];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layerAnimation.fromValue = [NSNumber numberWithFloat:0.0];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layerAnimation.toValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(360.0)];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layerAnimation.byValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(180.0)];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [manLayer addAnimation:layerAnimation forKey:@"layerAnimation"];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; completion:^(BOOL finished){&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Now do the second half of the view rotation.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; [UIView animateWithDuration:1.0&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; delay: 0.0&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; options: UIViewAnimationOptionCurveLinear&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; animations:^{&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CGAffineTransform&amp;nbsp; xform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(-359));&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; backingView.transform = xform;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; completion:^(BOOL finished){&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; backingView.transform = CGAffineTransformIdentity;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="middle"&gt;&lt;p&gt;}];&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&amp;nbsp;In &lt;span&gt;Listing 4-9&lt;/span&gt;, you could also create and apply the &lt;span&gt;CABasicAnimation&lt;/span&gt; object outside of the view-based animation block to achieve the same results. All of the animations ultimately rely on Core Animation for their execution. Thus, if they are submitted at approximately the same time, they run together.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;If precise timing between your view and layer based animations is required, it is recommended that you create all of the animations using Core Animation. You may find that some animations are easier to perform using Core Animation anyway. For example, the view-based rotation in &lt;span&gt;Listing 4-9&lt;/span&gt; requires a multistep sequence for rotations of more than 180 degrees, whereas the Core Animation portion uses a rotation value function that rotates from start to finish through a middle value.&lt;/p&gt;&lt;h1 id="pageTitle"&gt;Animation&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Animation is a key element of today&amp;rsquo;s user interfaces. When using Core Animation animation is completely automatic. There are no animation loops or timers. Your application is not responsible for frame by frame drawing, or tracking the current state of your animation. The animation occurs automatically in a separate thread, without further interaction with your application.&lt;/p&gt;&lt;p&gt;This chapter provides an overview of the animation classes, and describes how to create both implicit and explicit animations.&lt;/p&gt;&lt;p&gt;&lt;a title="Animation Classes and Timing" name="//apple_ref/doc/uid/TP40006085-SW6"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2 class="jump"&gt;Animation Classes and Timing&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Core Animation provides an expressive set of animation classes you can use in your application:&lt;/p&gt;&lt;ul class="ul"&gt;&lt;li class="li"&gt;&lt;p&gt;&lt;code&gt;CABasicAnimation&lt;/code&gt;&amp;nbsp;provides simple interpolation between values for a layer property.&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;&lt;code&gt;CAKeyframeAnimation&lt;/code&gt;&amp;nbsp;provides support for key frame animation. You specify the key path of the layer property to be animated, an array of values that represent the value at each stage of the animation, as well as arrays of key frame times and timing functions. As the animation runs, each value is set in turn using the specified interpolation.&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;&lt;code&gt;CATransition&lt;/code&gt;&amp;nbsp;provides a transition effect that affects the entire layer's content. It fades, pushes, or reveals layer content when animating. The stock transition effects can be extended by providing your own custom Core Image filters.&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;&lt;code&gt;CAAnimationGroup&lt;/code&gt;&amp;nbsp;allows an array of animation objects to be grouped together and run concurrently.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;In addition to specifying the type of animation to perform, you must also specify the duration of the animation, the pacing (how the interpolated values are distributed across the duration), if the animation is to repeat and how many times, whether it should automatically reverse when each cycle is completed, and its visual state when the animation is completed. The animation classes and the&amp;nbsp;&lt;code&gt;CAMediaTiming&lt;/code&gt;&amp;nbsp;protocol provides all this functionality and more.&lt;/p&gt;&lt;p&gt;&lt;code&gt;CAAnimation&lt;/code&gt;&amp;nbsp;and its subclasses and the timing protocols are shared by both Core Animation and the Cocoa Animation Proxy functionality. The classes are described in detail in&amp;nbsp;&lt;em&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/Animation_Types_Timing/Introduction/Introduction.html#//apple_ref/doc/uid/TP40006166" target="_self"&gt;Animation Types and Timing Programming Guide&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;&lt;a title="Implicit Animation" name="//apple_ref/doc/uid/TP40006085-SW7"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2 class="jump"&gt;Implicit Animation&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Core Animation&amp;rsquo;s implicit animation model assumes that all changes to animatable layer properties should be gradual and asynchronous. Dynamically animated scenes can be achieved without ever explicitly animating layers. Changing the value of an animatable layer property causes the layer to implicitly animate the change from the old value to the new value. While an animation is in-flight, setting a new target value causes the animation transition to the new target value from its current state.&lt;/p&gt;&lt;p&gt;&lt;span class="content_text"&gt;Listing 1&lt;/span&gt;&amp;nbsp;shows how simple it is to trigger an implicit animation that animates a layer from its current position to a new position.&lt;/p&gt;&lt;p&gt;&lt;a title="Listing 1Implicitly animating a layer&amp;rsquo;s position property" name="//apple_ref/doc/uid/TP40006085-SW2"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="codesample clear"&gt;&lt;strong class="caption_number"&gt;Listing 1&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Implicitly animating a layer&amp;rsquo;s position property&lt;/p&gt;&lt;div class="codesample clear"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td scope="row"&gt;// assume that the layer is current positioned at (100.0,100.0)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;theLayer.position=CGPointMake(500.0,500.0);&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;You can implicitly animate a single layer property at a time, or many. You can also implicitly animate several layers simultaneously. The code in&amp;nbsp;&lt;span class="content_text"&gt;Listing 2&lt;/span&gt;&amp;nbsp;causes four implicit animations to occur simultaneously.&lt;/p&gt;&lt;p&gt;&lt;a title="Listing 2Implicitly animating multiple properties of multiple layers" name="//apple_ref/doc/uid/TP40006085-SW3"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="codesample clear"&gt;&lt;strong class="caption_number"&gt;Listing 2&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Implicitly animating multiple properties of multiple layers&lt;/p&gt;&lt;div class="codesample clear"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td scope="row"&gt;// animate theLayer's opacity to 0 while moving it&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// further away in the layer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;theLayer.opacity=0.0;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;theLayer.zPosition=-100;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// animate anotherLayer's opacity to 1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;//  while moving it closer in the layer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;anotherLayer.opacity=1.0;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;anotherLayer.zPosition=100.0;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;Implicit animations use the duration specified in the default animation for the property, unless the duration has been overridden in an implicit or explicit transaction. See&amp;nbsp;&lt;span class="content_text"&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleLion.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Transactions.html#//apple_ref/doc/uid/TP40006096-SW7"&gt;&amp;ldquo;Overriding the Duration of Implied Animations&amp;rdquo;&lt;/a&gt;&lt;/span&gt;&amp;nbsp;for more information.&lt;/p&gt;&lt;p&gt;&lt;a title="Explicit Animation" name="//apple_ref/doc/uid/TP40006085-SW8"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2 class="jump"&gt;Explicit Animation&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Core Animation also supports an explicit animation model. The explicit animation model requires that you create an animation object, and set start and end values. An explicit animation won&amp;rsquo;t start until you apply the animation to a layer. The code fragment in&amp;nbsp;&lt;span class="content_text"&gt;Listing 3&lt;/span&gt;&amp;nbsp;creates an explicit animation that transitions a layer&amp;rsquo;s opacity from fully opaque to fully transparent, and back over a 3 second duration. The animation doesn&amp;rsquo;t begin until it is added to the layer.&lt;/p&gt;&lt;p&gt;&lt;a title="Listing 3Explicit animation" name="//apple_ref/doc/uid/TP40006085-SW4"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="codesample clear"&gt;&lt;strong class="caption_number"&gt;Listing 3&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Explicit animation&lt;/p&gt;&lt;div class="codesample clear"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td scope="row"&gt;CABasicAnimation *theAnimation;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;theAnimation.duration=3.0;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;theAnimation.repeatCount=2;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;theAnimation.autoreverses=YES;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;theAnimation.fromValue=[NSNumber numberWithFloat:1.0];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;theAnimation.toValue=[NSNumber numberWithFloat:0.0];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;[theLayer addAnimation:theAnimation forKey:@"animateOpacity"];&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;Explicit animations are especially useful when creating animations that run continuously.&amp;nbsp;&lt;span class="content_text"&gt;Listing 4&lt;/span&gt;&amp;nbsp;shows how to create an explicit animation that applies a CoreImage bloom filter to a layer, animating its intensity. This causes the &amp;ldquo;selection layer&amp;rdquo; to pulse, drawing the user&amp;rsquo;s attention.&lt;/p&gt;&lt;p&gt;&lt;a title="Listing 4Continuous explicit animation example" name="//apple_ref/doc/uid/TP40006085-SW5"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="codesample clear"&gt;&lt;strong class="caption_number"&gt;Listing 4&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Continuous explicit animation example&lt;/p&gt;&lt;div class="codesample clear"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// The selection layer will pulse continuously.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// This is accomplished by setting a bloom filter on the layer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// create the filter and set its default values&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;CIFilter *filter = [CIFilter filterWithName:@"CIBloom"];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;[filter setDefaults];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;[filter setValue:[NSNumber numberWithFloat:5.0] forKey:@"inputRadius"];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// name the filter so we can use the keypath to animate the inputIntensity&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// attribute of the filter&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;[filter setName:@"pulseFilter"];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// set the filter to the selection layer's filters&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;[selectionLayer setFilters:[NSArray arrayWithObject:filter]];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// create the animation that will handle the pulsing.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;CABasicAnimation* pulseAnimation = [CABasicAnimation animation];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// the attribute we want to animate is the inputIntensity&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// of the pulseFilter&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;pulseAnimation.keyPath = @"filters.pulseFilter.inputIntensity";&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// we want it to animate from the value 0 to 1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;pulseAnimation.fromValue = [NSNumber numberWithFloat: 0.0];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;pulseAnimation.toValue = [NSNumber numberWithFloat: 1.5];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// over a one second duration, and run an infinite&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// number of times&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;pulseAnimation.duration = 1.0;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;pulseAnimation.repeatCount = HUGE_VALF;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// we want it to fade on, and fade off, so it needs to&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// automatically autoreverse.. this causes the intensity&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// input to go from 0 to 1 to 0&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;pulseAnimation.autoreverses = YES;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// use a timing curve of easy in, easy out..&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;pulseAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// add the animation to the selection layer. This causes&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// it to begin animating. We'll use pulseAnimation as the&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// animation key name&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;[selectionLayer addAnimation:pulseAnimation forKey:@"pulseAnimation"];&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;a title="Starting and Stopping Explicit Animations" name="//apple_ref/doc/uid/TP40006085-SW9"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h2 class="jump"&gt;Starting and Stopping Explicit Animations&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;You start an explicit animation by sending a&amp;nbsp;&lt;code&gt;addAnimation:forKey:&lt;/code&gt;&amp;nbsp;message to the target layer, passing the animation and an identifier as parameters. Once added to the target layer the explicit animation will run until the animation completes, or it is removed from the layer. The identifier used to add an animation to a layer is also used to stop it by invoking&amp;nbsp;&lt;code&gt;removeAnimationForKey:&lt;/code&gt;. You can stop all animations for a layer by sending the layer a&amp;nbsp;&lt;code&gt;removeAllAnimations&lt;/code&gt;&amp;nbsp;message.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2479121.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/05/02/2479121.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/04/23/2466343.html</id><title type="text">Managing Nib Objects in iOS</title><summary type="text">Managing Nib Objects in iOSTop-Level ObjectsObjects in the nib file are created with a retain count of 1 and then autoreleased. As it rebuilds the object hierarchy, UIKit reestablishes connections between the objects usingsetValue:forKey:, which uses the available setter method or retains the object</summary><published>2012-04-23T05:55:00Z</published><updated>2012-04-23T05:55:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/04/23/2466343.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/04/23/2466343.html"/><content type="html">&lt;h4 class="jump"&gt;Managing Nib Objects in iOS&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a title="Top-Level Objects" name="//apple_ref/doc/uid/10000051i-CH4-SW37"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h5 class="jump"&gt;Top-Level Objects&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="color: #ff0000;"&gt;Objects in the nib file are created with a retain count of 1 and then autoreleased.&lt;/span&gt; As it rebuilds the object hierarchy, UIKit reestablishes connections between the objects using&amp;nbsp;&lt;code&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueCoding_Protocol/Reference/Reference.html#//apple_ref/occ/instm/NSObject/setValue:forKey:" target="_self"&gt;setValue:forKey:&lt;/a&gt;&lt;/code&gt;, which uses the available setter method or retains the object by default if no setter method is available. This means that (assuming you follow the pattern shown above)&amp;nbsp;&lt;em&gt;any object for which you have an outlet&lt;/em&gt;&amp;nbsp;remains valid. &lt;span style="color: #ff0000;"&gt;If there are any&amp;nbsp;&lt;em&gt;top-level&lt;/em&gt;&amp;nbsp;objects you do not store in outlets, however, you must retain either the array returned by the&amp;nbsp;&lt;code&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/NSBundle_UIKitAdditions/Introduction/Introduction.html#//apple_ref/occ/instm/NSBundle/loadNibNamed:owner:options:" target="_self"&gt;&lt;span style="color: #ff0000;"&gt;loadNibNamed:owner:options:&lt;/span&gt;&lt;/a&gt;&lt;/code&gt;&amp;nbsp;method or the objects inside the array to prevent those objects from being released prematurely.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a title="Memory Warnings" name="//apple_ref/doc/uid/10000051i-CH4-SW38"&gt;&lt;/a&gt;&lt;/p&gt;&lt;h5 class="jump"&gt;Memory Warnings&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;When a view controller receives a memory warning (&lt;code&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/didReceiveMemoryWarning" target="_self"&gt;didReceiveMemoryWarning&lt;/a&gt;&lt;/code&gt;), it should relinquish ownership of resources that are currently not needed and that can be recreated later if required. One such resource is the view controller's view itself. If it does not have a superview, the view is disposed of (in its implementation of&amp;nbsp;&lt;code&gt;didReceiveMemoryWarning&lt;/code&gt;,&amp;nbsp;&lt;code&gt;UIViewController&lt;/code&gt;&amp;nbsp;invokes&amp;nbsp;&lt;code&gt;[self setView:nil]&lt;/code&gt;).&lt;/p&gt;&lt;p&gt;Because outlets to elements within the nib file are typically retained, however, even though the main view is disposed of, absent any further action the outlets are not disposed of. This is not in and of itself a problem&amp;mdash;if and when the main view is reloaded, they will simply be replaced&amp;mdash;but it does mean that the beneficial effect of the&amp;nbsp;&lt;code&gt;didReceiveMemoryWarning&lt;/code&gt;&amp;nbsp;is reduced. To ensure that you properly relinquish ownership of outlets, in your custom view controller class you can implement&amp;nbsp;&lt;code&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/viewDidUnload" target="_self"&gt;viewDidUnload&lt;/a&gt;&lt;/code&gt;&amp;nbsp;to invoke your accessor methods to set outlets to&amp;nbsp;&lt;code&gt;nil&lt;/code&gt;.&lt;/p&gt;&lt;div class="codesample clear"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td scope="row"&gt;- (void)viewDidUnload {&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    self.anOutlet = nil;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    [super viewDidUnload];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 class="jump"&gt;Managing the Lifetimes of Objects from Nib Files&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Each time you ask the&amp;nbsp;&lt;code&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html#//apple_ref/occ/cl/NSBundle" target="_self"&gt;NSBundle&lt;/a&gt;&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code&gt;NSNib&lt;/code&gt;&amp;nbsp;class to load a nib file, the underlying code creates a new&amp;nbsp;&lt;span class="pediaLink" data-header="Object copying" data-contents="Copying an object creates a new object with the same class and properties as the original object. "&gt;&lt;a target="_self" data-href="http://www.cnblogs.com/http://www.cnblogs.com/General/Conceptual/DevPedia-CocoaCore/ObjectCopying.html#//apple_ref/doc/uid/TP40008195-CH38"&gt;copy&lt;/a&gt;&lt;/span&gt;&amp;nbsp;of the objects in that file and returns them to you. (The nib-loading code does not recycle nib file objects from a previous load attempt.) You need to ensure that you maintain the new object graph as long as necessary, and disown it when you are finished with it. You typically need strong references to top-level objects to ensure that they are not deallocated; you don&amp;rsquo;t need strong references to objects lower down in the graph because they&amp;rsquo;re owned by their parents, and you should minimize the risk of creating strong reference cycles.&lt;/p&gt;&lt;p&gt;&lt;span style="color: #ff0000;"&gt;From a practical perspective, in iOS and OS X outlets should be defined as&amp;nbsp;&lt;span class="pediaLink" data-header="Declared property" data-contents="A declared property provides a syntactical shorthand for declaring a class&amp;rsquo;s accessor methods and, optionally, implementing them. "&gt;&lt;a target="_self" data-href="http://www.cnblogs.com/http://www.cnblogs.com/General/Conceptual/DevPedia-CocoaCore/DeclaredProperty.html#//apple_ref/doc/uid/TP40008195-CH13"&gt;&lt;span style="color: #ff0000;"&gt;declared properties&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;. Outlets should generally be&amp;nbsp;&lt;code&gt;weak&lt;/code&gt;, except for those from File&amp;rsquo;s Owner to top-level objects in a nib file (or, in iOS, a storyboard scene) which should be&amp;nbsp;&lt;code&gt;strong&lt;/code&gt;. Outlets that you create should will therefore typically be&amp;nbsp;&lt;code&gt;weak&lt;/code&gt;&amp;nbsp;by default&lt;/span&gt;, because:&lt;/p&gt;&lt;ul class="ul"&gt;&lt;li class="li"&gt;&lt;p&gt;Outlets that you create to, for example, subviews of a view controller&amp;rsquo;s view or a window controller&amp;rsquo;s window, are arbitrary references between objects that do not imply ownership.&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;The strong outlets are frequently specified by framework classes (for example,&amp;nbsp;&lt;code&gt;UIViewController&lt;/code&gt;&amp;rsquo;s&amp;nbsp;&lt;code&gt;view&lt;/code&gt;&amp;nbsp;outlet, or&amp;nbsp;&lt;code&gt;NSWindowController&lt;/code&gt;&amp;rsquo;s&amp;nbsp;&lt;code&gt;window&lt;/code&gt;&amp;nbsp;outlet).&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="codesample clear"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td scope="row"&gt;@property (weak) IBOutlet MyView *viewContainerSubview;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;@property (strong) IBOutlet MyOtherClass *topLevelObject;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h3 class="jump"&gt;Getting a Nib File&amp;rsquo;s Top-Level Objects&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;The easiest way to get the top-level objects of your nib file is to define outlets in the File&amp;rsquo;s Owner object along with setter methods (or better yet, properties) for accessing those objects. This approach ensures that the top-level objects are retained by your object and that you always have references to them.&lt;/p&gt;&lt;p&gt;&lt;span class="content_text"&gt;Listing 1-3&lt;/span&gt;&amp;nbsp;shows the interface and implementation of a simplified Cocoa class that uses an outlet to retain the nib file&amp;rsquo;s only top-level object. In this case, the only top-level object in the nib file is an&amp;nbsp;&lt;code&gt;NSWindow&lt;/code&gt;&amp;nbsp;object. &lt;span style="color: #ff0000;"&gt;Because top-level objects in Cocoa have an initial retain count of 1, an extra release message is included.&lt;/span&gt; This is fine because by the time the release call is made, the property has already been retained the window. You would not want to release top-level objects in this manner in an iPhone application.&lt;/p&gt;&lt;p&gt;&lt;a title="Listing 1-3Using outlets to get the top-level objects" name="//apple_ref/doc/uid/10000051i-CH4-SW33"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="codesample clear"&gt;&lt;strong class="caption_number"&gt;Listing 1-3&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Using outlets to get the top-level objects&lt;/p&gt;&lt;div class="codesample clear"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td scope="row"&gt;// Class interface&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;@interface MyController : NSObject {&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    NSWindow *window;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;@property(retain) IBOutlet NSWindow *window;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;- (void)loadMyWindow;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;@end&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// Class implementation&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;@implementation MyController&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;// The synthesized property retains the window automatically.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;@synthesize window;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;- (void)loadMyWindow&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    [NSBundle loadNibNamed:@"myNib" owner:self];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    // The window starts off with a retain count of 1&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    // and is then retained by the property, so add an extra release.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    [window release];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;@end&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;If you do not want to use outlets to store references to your nib file&amp;rsquo;s top-level objects, you must retrieve those objects manually in your code. The technique for obtaining the top-level objects differs depending on the target platform. In OS X, you must ask for the objects explicitly, whereas in iOS they are returned to you automatically.&lt;/p&gt;&lt;p&gt;&lt;span class="content_text"&gt;Listing 1-4&lt;/span&gt;&amp;nbsp;shows the process for getting the top-level objects of a nib file in OS X. This method places a mutable array into the&amp;nbsp;&lt;code&gt;nameTable&lt;/code&gt;&amp;nbsp;dictionary and associates it with the&amp;nbsp;&lt;code&gt;NSNibTopLevelObjects&lt;/code&gt;&amp;nbsp;key. The nib-loading code looks for this array object and, if present, places the top-level objects in it. &lt;span style="color: #ff0000;"&gt;Because each object starts with a retain count of 1 before it is added to the array, simply releasing the array is not enough to release the objects in the array as well. As a result, this method sends a release message to each of the objects to ensure that the array is the only entity holding a reference to them.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a title="Listing 1-4Getting the top-level objects from a nib file at runtime" name="//apple_ref/doc/uid/10000051i-CH4-SW27"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="codesample clear"&gt;&lt;strong class="caption_number"&gt;Listing 1-4&lt;/strong&gt;&amp;nbsp;&amp;nbsp;Getting the top-level objects from a nib file at runtime&lt;/p&gt;&lt;div class="codesample clear"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td scope="row"&gt;- (NSArray*)loadMyNibFile&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;{&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    NSBundle*            aBundle = [NSBundle mainBundle];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    NSMutableArray*      topLevelObjs = [NSMutableArray array];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    NSDictionary*        nameTable = [NSDictionary dictionaryWithObjectsAndKeys:&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;                                            self, NSNibOwner,&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;                                            topLevelObjs, NSNibTopLevelObjects,&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;                                            nil];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    if (![aBundle loadNibFile:@"myNib" externalNameTable:nameTable withZone:nil])&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    {&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;        NSLog(@"Warning! Could not load myNib file.\n");&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;        return nil;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    }&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    // Release the objects so that they are just owned by the array.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    [topLevelObjs makeObjectsPerformSelector:@selector(release)];&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;    return topLevelObjs;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td scope="row"&gt;}&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;Obtaining the top-level objects in an iPhone application is much simpler and is shown in&amp;nbsp;&lt;span class="content_text"&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html#//apple_ref/doc/uid/10000051i-CH4-SW11"&gt;Listing 1-2&lt;/a&gt;&lt;/span&gt;. In the UIKit framework, the&amp;nbsp;&lt;code&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/NSBundle_UIKitAdditions/Introduction/Introduction.html#//apple_ref/occ/instm/NSBundle/loadNibNamed:owner:options:" target="_self"&gt;loadNibNamed:owner:options:&lt;/a&gt;&lt;/code&gt;&amp;nbsp;method of&amp;nbsp;&lt;code&gt;&lt;a href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html#//apple_ref/occ/cl/NSBundle" target="_self"&gt;NSBundle&lt;/a&gt;&lt;/code&gt;&amp;nbsp;automatically returns an array with the top-level objects. In addition, by the time the array is returned, the retain counts on the objects are adjusted so that you do not need to send each object an extra release message. The returned array is the only owner of the objects.&lt;/p&gt;&lt;div&gt;&amp;nbsp;&lt;/div&gt;&lt;p&gt;&lt;a title="Loading Nib Files Using UINib and NSNib" name="//apple_ref/doc/uid/10000051i-CH4-SW28"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;a title="Managing Nib Objects in OS&amp;nbsp;X" name="//apple_ref/doc/uid/10000051i-CH4-SW39"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2466343.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/04/23/2466343.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/ioriwellings/archive/2012/04/20/2459558.html</id><title type="text">Specifying High-Resolution Images in iOS</title><summary type="text">Specifying High-Resolution Images in iOSAny iPhone application built for iOS 4.0 and later should include high-resolution versions of its image resources. When the application is run on a device that has a high-resolution screen, high-resolution images provide extra detail and look better because th</summary><published>2012-04-20T08:46:00Z</published><updated>2012-04-20T08:46:00Z</updated><author><name>不及格的程序员-八神</name><uri>http://www.cnblogs.com/ioriwellings/</uri></author><link rel="alternate" href="http://www.cnblogs.com/ioriwellings/archive/2012/04/20/2459558.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/ioriwellings/archive/2012/04/20/2459558.html"/><content type="html">&lt;h3 class="jump" style="margin-top: 1.5em; margin-bottom: 0.25em; font-size: 19px; font-weight: normal; color: #000000;"&gt;Specifying High-Resolution Images in iOS&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Any iPhone application built for iOS 4.0 and later should include high-resolution versions of its image resources. When the application is run on a device that has a high-resolution screen, high-resolution images provide extra detail and look better because they do not need to be scaled to fit the space. You provide high-resolution images for each image resource in your application bundle, including icons and launch images.&lt;/p&gt;&lt;p&gt;To specify a high-resolution version of an image, create a version whose width and height (measured in pixels) are twice that of the original. (You can use the extra pixels in the image to provide additional detail.) When saving the image, use the same base name but include the string&amp;nbsp;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;@2x&lt;/code&gt;&amp;nbsp;between the base filename and the filename extension. For example, if you have an image named&amp;nbsp;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;MyImage.png&lt;/code&gt;, the name of the high-resolution version would be&amp;nbsp;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;MyImage@2x.png&lt;/code&gt;. Put the high-resolution and original versions of your image in the same location in your application bundle.&lt;/p&gt;&lt;p&gt;The bundle- and image-loading routines automatically look for image files with the&amp;nbsp;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;@2x&lt;/code&gt;&amp;nbsp;string when the underlying device has a high-resolution screen. If you combine the&amp;nbsp;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;@2x&lt;/code&gt;&amp;nbsp;string with other modifiers, the&amp;nbsp;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;@2x&lt;/code&gt;&amp;nbsp;string should come before any device modifiers but after all other modifiers, such as launch orientation or URL scheme modifiers. Thus, a universal application might have the following image resource files for a single image:&lt;/p&gt;&lt;ul class="simple" style="list-style-type: none; list-style-position: outside; list-style-image: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2.5em; padding-top: 0px; padding-right: 0px; padding-bottom: 0.5em; padding-left: 0px;"&gt;&lt;li style="margin-top: 1px;"&gt;&lt;p&gt;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;MyImage.png&lt;/code&gt;&amp;nbsp;- Default version of the image resource, which is also used for iPad.&lt;/p&gt;&lt;/li&gt;&lt;li style="margin-top: 1px;"&gt;&lt;p&gt;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;MyImage~iphone.png&lt;/code&gt;&amp;nbsp;- Version of the image for iPhone and iPod touch.&lt;/p&gt;&lt;/li&gt;&lt;li style="margin-top: 1px;"&gt;&lt;p&gt;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;MyImage@2x~iphone.png&lt;/code&gt;&amp;nbsp;- High-resolution version of an image for iPhone and iPod touch devices with Retina displays.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;span style="color: #ff0000;"&gt;&lt;strong&gt;When you want to load an image, do not include the&amp;nbsp;&lt;span style="color: #0000ff;"&gt;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;@2x&lt;/code&gt;&lt;/span&gt;&amp;nbsp;or any device modifiers when specifying the image name in your code.&lt;/strong&gt;&lt;/span&gt; For example, &lt;strong&gt;&lt;span style="color: #0000ff;"&gt;if your application bundle included the image files from the preceding list&lt;/span&gt;&lt;/strong&gt;, you would ask for an image named&amp;nbsp;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;MyImage.png&lt;/code&gt;. The system automatically determines which version of the image is most appropriate and loads it. Similarly, when using or drawing that image, you do not have to know whether it is the original resolution or high-resolution version. The image-drawing routines automatically adjust based on the image that was loaded. However, if you still want to know whether an image is the original or high-resolution version, you can check its scale factor. If the image is the high-resolution version, its scale factor is set to a value other than&amp;nbsp;&lt;code style="font-size: 13px; font-family: Courier, Consolas, monospace; color: #666666;"&gt;1.0&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;For more information about how to support high-resolution devices, see&amp;nbsp;&lt;span class="content_text" style="margin-top: 0px; font: normal normal normal 100%/normal 'Lucida Grande', Geneva, Helvetica, Arial, sans-serif; margin-bottom: 0.833em; padding-bottom: 0.833em; vertical-align: top;"&gt;&lt;a style="color: #3366cc; text-decoration: none;" href="file:///Users/yangiori/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS5_1.iOSLibrary.docset/Contents/Resources/Documents/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/SupportingHiResScreens/SupportingHiResScreens.html#//apple_ref/doc/uid/TP40010156-CH15" target="_self"&gt;&amp;ldquo;Supporting High-Resolution Screens&amp;rdquo;&lt;/a&gt;&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Resource Programming Guide&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;iOS Supports Device-Specific Resources&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;In iOS 4.0 and later, it is possible to mark individual resource files as usable only on a specific type of device. This capability simplifies the code you have to write for Universal applications. Rather than creating separate code paths to load one version of a resource file for iPhone and a different version of the file for iPad, you can let the bundle-loading routines choose the correct file. All you have to do is name your resource files appropriately.&lt;/p&gt;&lt;p&gt;To associate a resource file with a particular device, you add a custom modifier string to its filename. The inclusion of this modifier string yields filenames with the following format:&lt;/p&gt;&lt;p&gt;&lt;em&gt;&amp;lt;basename&amp;gt;&lt;/em&gt;&lt;em&gt;&amp;lt;device&amp;gt;&lt;/em&gt;&lt;code&gt;.&lt;/code&gt;&lt;em&gt;&amp;lt;filename_extension&amp;gt;&lt;/em&gt;&lt;/p&gt;&lt;p&gt;The&amp;nbsp;&lt;em&gt;&amp;lt;basename&amp;gt;&lt;/em&gt;&amp;nbsp;string represents the original name of the resource file. It also represents the name you use when accessing the file from your code. Similarly, the&amp;nbsp;&lt;em&gt;&amp;lt;filename_extension&amp;gt;&lt;/em&gt;&amp;nbsp;string is the standard filename extension used to identify the type of the file. The&amp;nbsp;&lt;em&gt;&amp;lt;device&amp;gt;&lt;/em&gt;&amp;nbsp;string is a case-sensitive string that can be one of the following values:&lt;/p&gt;&lt;ul class="ul"&gt;&lt;li class="li"&gt;&lt;p&gt;&lt;code&gt;~ipad&lt;/code&gt;&amp;nbsp;- The resource should be loaded on iPad devices only.&lt;/p&gt;&lt;/li&gt;&lt;li class="li"&gt;&lt;p&gt;&lt;code&gt;~iphone&lt;/code&gt;&amp;nbsp;- The resource should be loaded on iPhone or iPod touch devices only.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;You can apply device modifiers to any type of resource file. For example, suppose you have an image named&amp;nbsp;&lt;code&gt;MyImage.png&lt;/code&gt;. To specify different versions of the image for iPad and iPhone, you would create resource files with the names&amp;nbsp;&lt;code&gt;MyImage~ipad.png&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code&gt;MyImage~iphone.png&lt;/code&gt;&amp;nbsp;and include them both in your bundle. To load the image, you would continue to refer to the resource as&amp;nbsp;&lt;code&gt;MyImage.png&lt;/code&gt;&amp;nbsp;in your code and let the system choose the appropriate version, as shown here:&lt;/p&gt;&lt;div class="codesample clear"&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td scope="row"&gt;UIImage* anImage = [UIImage imageNamed:@"MyImage.png"];&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;On an iPhone or iPod touch device, the system loads the&amp;nbsp;&lt;code&gt;MyImage~iphone.png&lt;/code&gt;&amp;nbsp;resource file, while on iPad, it loads the&amp;nbsp;&lt;code&gt;MyImage~ipad.png&lt;/code&gt;&amp;nbsp;resource file. &lt;span style="color: #ff0000;"&gt;If a device-specific version of a resource is not found, the system falls back to looking for a resource with the original filename, which in the preceding example would be an image named&amp;nbsp;&lt;code&gt;MyImage.png&lt;/code&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div id="introSeeAlsoSection"&gt;&lt;a title="See Also" name="//apple_ref/doc/uid/10000051i-CH1-DontLinkElementID_3"&gt;&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.cnblogs.com/ioriwellings/aggbug/2459558.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/ioriwellings/archive/2012/04/20/2459558.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry></feed>
