<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">博客园_还有多少青春可以挥霍</title><subtitle type="text">这刻在望著父亲笑容时,竟不知不觉的无言</subtitle><id>http://feed.cnblogs.com/blog/u/30877/rss</id><updated>2012-05-30T05:45:38Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><generator>feed.cnblogs.com</generator><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/"/><link rel="self" type="application/atom+xml" href="http://feed.cnblogs.com/blog/u/30877/rss"/><entry><id>http://www.cnblogs.com/kkun/archive/2012/05/30/2526146.html</id><title type="text">No package nginx available. |一次解决一个问题</title><summary type="text">No package nginx available. |一次解决一个问题 今天在新买的vps上安装nginx时提示没有nginx的包可安装 问题现场 [root@localhost ~]# yum -y install nginx Loaded plugins: fastestmirror Loading mirror speeds from cach...</summary><published>2012-05-30T05:40:00Z</published><updated>2012-05-30T05:40:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2012/05/30/2526146.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2012/05/30/2526146.html"/><content type="html">&lt;p&gt;&lt;font face="宋体"&gt;No package nginx available.&amp;#160; |一次解决一个问题     &lt;hr /&gt;今天在新买的vps上安装nginx时提示没有nginx的包可安装      &lt;hr /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;问题现场&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;[root@localhost ~]# yum -y install nginx     &lt;br /&gt;Loaded plugins: fastestmirror      &lt;br /&gt;Loading mirror speeds from cached hostfile      &lt;br /&gt;* addons: centos.ustc.edu.cn      &lt;br /&gt;* base: centos.ustc.edu.cn      &lt;br /&gt;* extras: centos.ustc.edu.cn      &lt;br /&gt;* updates: data.nicehosting.co.kr      &lt;br /&gt;Setting up Install Process      &lt;br /&gt;&lt;font style="background-color: #ffff00"&gt;No package nginx available.&lt;/font&gt;      &lt;br /&gt;Nothing to do      &lt;hr /&gt;解决方法&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://winhows.net/search/no-package-nginx-available-yum/"&gt;&lt;font face="宋体"&gt;http://winhows.net/search/no-package-nginx-available-yum/&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;在使用上述方法解决问题时发现,文中指示的 rpm包不可用,下载不了,404&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.cyberciti.biz/faq/rhel-fedora-centos-linux-enable-epel-repo/"&gt;&lt;font face="宋体"&gt;http://www.cyberciti.biz/faq/rhel-fedora-centos-linux-enable-epel-repo/&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;上述地址中的方法肯定了必须要解决 EPEL才可以安装nginx,问题转为寻找一个可用的rpm包&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;问题转为:&lt;font style="background-color: #ffff00"&gt;How Do I Enable EPEL Repo under CentOS or RHEL Servers?&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://rpm.pbone.net/index.php3/stat/4/idpl/15297742/dir/fedora_6/com/epel-release-6-5.noarch.rpm.html"&gt;&lt;font face="宋体"&gt;http://rpm.pbone.net/index.php3/stat/4/idpl/15297742/dir/fedora_6/com/epel-release-6-5.noarch.rpm.html&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;使用命令:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;rpm -Uvh &lt;/font&gt;&lt;a title="ftp://ftp.univie.ac.at/systems/linux/fedora/epel/beta/6/i386/epel-release-6-5.noarch.rpm" href="ftp://ftp.univie.ac.at/systems/linux/fedora/epel/beta/6/i386/epel-release-6-5.noarch.rpm"&gt;&lt;font face="宋体"&gt;ftp://ftp.univie.ac.at/systems/linux/fedora/epel/beta/6/i386/epel-release-6-5.noarch.rpm&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;以上内容即可启用EPEL,之后再次yum install nginx即可安装!&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205301339513673.png"&gt;&lt;font face="宋体"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(18)" border="0" alt="Image(18)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205301339511655.png" width="615" height="589" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;最终在此找到大量可用的rpm再次按照链接1文中提到的方法,解决战斗!&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205301339522702.png"&gt;&lt;font face="宋体"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(19)" border="0" alt="Image(19)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205301339521033.png" width="609" height="512" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205301339522952.png"&gt;&lt;font face="宋体"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(20)" border="0" alt="Image(20)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205301339532047.png" width="609" height="512" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;[root@303914 downloads]# rpm -Uvh &lt;/font&gt;&lt;a href="ftp://ftp.univie.ac.at/systems/linux/fedora/epel/beta/6/i386/epel-release-6-5.noarch.rpm"&gt;&lt;font face="宋体"&gt;ftp://ftp.univie.ac.at/systems/linux/fedora/epel/beta/6/i386/epel-release-6-5.noarch.rpm&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;Retrieving &lt;/font&gt;&lt;a href="ftp://ftp.univie.ac.at/systems/linux/fedora/epel/beta/6/i386/epel-release-6-5.noarch.rpm"&gt;&lt;font face="宋体"&gt;ftp://ftp.univie.ac.at/systems/linux/fedora/epel/beta/6/i386/epel-release-6-5.noarch.rpm&lt;/font&gt;&lt;/a&gt;    &lt;br /&gt;&lt;font face="宋体"&gt;warning: /var/tmp/rpm-tmp.xrqJSG: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY     &lt;br /&gt;Preparing...&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ########################################### [100%]      &lt;br /&gt;&amp;#160;&amp;#160; 1:epel-release&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ########################################### [100%]      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;[root@303914 downloads]# yum repolist     &lt;br /&gt;Loaded plugins: fastestmirror      &lt;br /&gt;Loading mirror speeds from cached hostfile      &lt;br /&gt;epel/metalink&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; |&amp;#160; 12 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt; * epel: mirrors.solfo.com      &lt;br /&gt;epel&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 4.0 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;epel/primary_db&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 3.6 MB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:01&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;repo id&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; repo name&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; status      &lt;br /&gt;base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CentOS-6 - Base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 4,764      &lt;br /&gt;epel&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Extra Packages for Enterprise Linux 6 - i386&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 6,061      &lt;br /&gt;extras&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CentOS-6 - Extras&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 4      &lt;br /&gt;updates&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; CentOS-6 - Updates&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 732      &lt;br /&gt;vz-base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; vz-base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 3      &lt;br /&gt;vz-updates&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; vz-updates&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 0      &lt;br /&gt;repolist: 11,564      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;[root@303914 downloads]# yum install nginx     &lt;br /&gt;Loaded plugins: fastestmirror      &lt;br /&gt;Loading mirror speeds from cached hostfile      &lt;br /&gt; * epel: mirrors.solfo.com      &lt;br /&gt;Setting up Install Process      &lt;br /&gt;Resolving Dependencies      &lt;br /&gt;--&amp;gt; Running transaction check      &lt;br /&gt;---&amp;gt; Package nginx.i686 0:1.0.15-1.el6 will be installed      &lt;br /&gt;--&amp;gt; Processing Dependency: libxslt.so.1(LIBXML2_1.0.18) for package: nginx-1.0.15-1.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: libxslt.so.1(LIBXML2_1.0.11) for package: nginx-1.0.15-1.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: libxslt.so.1 for package: nginx-1.0.15-1.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: libgd.so.2 for package: nginx-1.0.15-1.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: libexslt.so.0 for package: nginx-1.0.15-1.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: libGeoIP.so.1 for package: nginx-1.0.15-1.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: gd for package: nginx-1.0.15-1.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: GeoIP for package: nginx-1.0.15-1.el6.i686      &lt;br /&gt;--&amp;gt; Running transaction check      &lt;br /&gt;---&amp;gt; Package GeoIP.i686 0:1.4.8-1.el6 will be installed      &lt;br /&gt;---&amp;gt; Package gd.i686 0:2.0.35-10.el6 will be installed      &lt;br /&gt;--&amp;gt; Processing Dependency: libfontconfig.so.1 for package: gd-2.0.35-10.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: libX11.so.6 for package: gd-2.0.35-10.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: libXpm.so.4 for package: gd-2.0.35-10.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: libfreetype.so.6 for package: gd-2.0.35-10.el6.i686      &lt;br /&gt;---&amp;gt; Package libxslt.i686 0:1.1.26-2.el6 will be installed      &lt;br /&gt;--&amp;gt; Running transaction check      &lt;br /&gt;---&amp;gt; Package fontconfig.i686 0:2.8.0-3.el6 will be installed      &lt;br /&gt;---&amp;gt; Package freetype.i686 0:2.3.11-6.el6_2.9 will be installed      &lt;br /&gt;---&amp;gt; Package libX11.i686 0:1.3-2.el6 will be installed      &lt;br /&gt;--&amp;gt; Processing Dependency: libX11-common = 1.3-2.el6 for package: libX11-1.3-2.el6.i686      &lt;br /&gt;--&amp;gt; Processing Dependency: libxcb.so.1 for package: libX11-1.3-2.el6.i686      &lt;br /&gt;---&amp;gt; Package libXpm.i686 0:3.5.8-2.el6 will be installed      &lt;br /&gt;--&amp;gt; Running transaction check      &lt;br /&gt;---&amp;gt; Package libX11-common.noarch 0:1.3-2.el6 will be installed      &lt;br /&gt;---&amp;gt; Package libxcb.i686 0:1.5-1.el6 will be installed      &lt;br /&gt;--&amp;gt; Processing Dependency: libXau.so.6 for package: libxcb-1.5-1.el6.i686      &lt;br /&gt;--&amp;gt; Running transaction check      &lt;br /&gt;---&amp;gt; Package libXau.i686 0:1.0.5-1.el6 will be installed      &lt;br /&gt;--&amp;gt; Finished Dependency Resolution&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;Dependencies Resolved&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;================================================================================     &lt;br /&gt; Package&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Arch&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Version&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Repository&amp;#160;&amp;#160;&amp;#160;&amp;#160; Size      &lt;br /&gt;================================================================================      &lt;br /&gt;Installing:      &lt;br /&gt; nginx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 1.0.15-1.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; epel&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 381 k      &lt;br /&gt;Installing for dependencies:      &lt;br /&gt; GeoIP&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 1.4.8-1.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; epel&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 621 k      &lt;br /&gt; fontconfig&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2.8.0-3.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 186 k      &lt;br /&gt; freetype&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2.3.11-6.el6_2.9&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; updates&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 363 k      &lt;br /&gt; gd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2.0.35-10.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 141 k      &lt;br /&gt; libX11&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 1.3-2.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 585 k      &lt;br /&gt; libX11-common&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; noarch&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 1.3-2.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 188 k      &lt;br /&gt; libXau&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 1.0.5-1.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 22 k      &lt;br /&gt; libXpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 3.5.8-2.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 58 k      &lt;br /&gt; libxcb&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 1.5-1.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 104 k      &lt;br /&gt; libxslt&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 1.1.26-2.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; base&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 448 k&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;Transaction Summary     &lt;br /&gt;================================================================================      &lt;br /&gt;Install&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 11 Package(s)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;Total download size: 3.0 M     &lt;br /&gt;Installed size: 10 M      &lt;br /&gt;Is this ok [y/N]: y      &lt;br /&gt;Downloading Packages:      &lt;br /&gt;(1/11): GeoIP-1.4.8-1.el6.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 621 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(2/11): fontconfig-2.8.0-3.el6.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 186 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(3/11): freetype-2.3.11-6.el6_2.9.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 363 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(4/11): gd-2.0.35-10.el6.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 141 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(5/11): libX11-1.3-2.el6.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 585 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:01&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(6/11): libX11-common-1.3-2.el6.noarch.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 188 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(7/11): libXau-1.0.5-1.el6.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; |&amp;#160; 22 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(8/11): libXpm-3.5.8-2.el6.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; |&amp;#160; 58 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(9/11): libxcb-1.5-1.el6.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 104 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(10/11): libxslt-1.1.26-2.el6.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 448 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;(11/11): nginx-1.0.15-1.el6.i686.rpm&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; | 381 kB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:00&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;--------------------------------------------------------------------------------      &lt;br /&gt;Total&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 367 kB/s | 3.0 MB&amp;#160;&amp;#160;&amp;#160;&amp;#160; 00:08&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY      &lt;br /&gt;Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6      &lt;br /&gt;Importing GPG key 0x0608B895:      &lt;br /&gt; Userid : EPEL (6) &amp;lt;epel@fedoraproject.org&amp;gt;      &lt;br /&gt; Package: epel-release-6-5.noarch (installed)      &lt;br /&gt; From&amp;#160;&amp;#160; : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6      &lt;br /&gt;Is this ok [y/N]: y      &lt;br /&gt;Running rpm_check_debug      &lt;br /&gt;Running Transaction Test      &lt;br /&gt;Transaction Test Succeeded      &lt;br /&gt;Running Transaction      &lt;br /&gt;Warning: RPMDB altered outside of yum.      &lt;br /&gt;&amp;#160; Installing : freetype-2.3.11-6.el6_2.9.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 1/11       &lt;br /&gt;&amp;#160; Installing : libX11-common-1.3-2.el6.noarch&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 2/11       &lt;br /&gt;&amp;#160; Installing : fontconfig-2.8.0-3.el6.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 3/11       &lt;br /&gt;&amp;#160; Installing : GeoIP-1.4.8-1.el6.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 4/11       &lt;br /&gt;&amp;#160; Installing : libxslt-1.1.26-2.el6.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 5/11       &lt;br /&gt;&amp;#160; Installing : libXau-1.0.5-1.el6.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 6/11       &lt;br /&gt;&amp;#160; Installing : libxcb-1.5-1.el6.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 7/11       &lt;br /&gt;&amp;#160; Installing : libX11-1.3-2.el6.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 8/11       &lt;br /&gt;&amp;#160; Installing : libXpm-3.5.8-2.el6.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 9/11       &lt;br /&gt;&amp;#160; Installing : gd-2.0.35-10.el6.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 10/11       &lt;br /&gt;&amp;#160; Installing : nginx-1.0.15-1.el6.i686&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 11/11 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;Installed:     &lt;br /&gt;&amp;#160; nginx.i686 0:1.0.15-1.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;Dependency Installed:     &lt;br /&gt;&amp;#160; GeoIP.i686 0:1.4.8-1.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; fontconfig.i686 0:2.8.0-3.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160; freetype.i686 0:2.3.11-6.el6_2.9&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; gd.i686 0:2.0.35-10.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160; libX11.i686 0:1.3-2.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; libX11-common.noarch 0:1.3-2.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160; libXau.i686 0:1.0.5-1.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; libXpm.i686 0:3.5.8-2.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160; libxcb.i686 0:1.5-1.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; libxslt.i686 0:1.1.26-2.el6&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="宋体"&gt;Complete!     &lt;br /&gt;      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2526146.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2012/05/30/2526146.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/kkun/archive/2012/05/03/linux-3.html</id><title type="text">Linux学习笔记之三</title><summary type="text">Linux学习三#设置固定IP原因是虚机重启后IP变了,这样SSH时就要先知道IP才行,麻烦第一种（立即生效，重启后配置丢失）ifconfig eth0 192.168.0.10 netmask 255.255.255.0ifconfig eth0 up第二种（重启后生效，重启电脑，IP不会丢失）vi /etc/sysconfig/network-scripts/ifcfg-eth0参考配置文件DEVICE=eth0ONBOOT=yesBOOTPROTO=staticIPADDR=192.168.0.10NETMASK=255.255.255.0GATEWAY=192.168.0.1HWADD</summary><published>2012-05-03T08:02:00Z</published><updated>2012-05-03T08:02:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2012/05/03/linux-3.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2012/05/03/linux-3.html"/><content type="html">&lt;p&gt;Linux学习三&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;#设置固定IP&lt;/p&gt;&lt;p&gt;原因是虚机重启后IP变了,这样SSH时就要先知道IP才行,麻烦&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;第一种（立即生效，重启后配置丢失）&lt;/p&gt;&lt;p&gt;ifconfig eth0 192.168.0.10 netmask 255.255.255.0&lt;/p&gt;&lt;p&gt;ifconfig eth0 up&lt;/p&gt;&lt;p&gt;第二种（重启后生效，重启电脑，IP不会丢失）&lt;/p&gt;&lt;p&gt;vi /etc/sysconfig/network-scripts/ifcfg-eth0&lt;/p&gt;&lt;p&gt;参考配置文件&lt;/p&gt;&lt;p&gt;DEVICE=eth0&lt;/p&gt;&lt;p&gt;ONBOOT=yes&lt;/p&gt;&lt;p&gt;BOOTPROTO=static&lt;/p&gt;&lt;p&gt;IPADDR=192.168.0.10&lt;/p&gt;&lt;p&gt;NETMASK=255.255.255.0&lt;/p&gt;&lt;p&gt;GATEWAY=192.168.0.1&lt;/p&gt;&lt;p&gt;HWADDR=00:0c:29:dd:a6:00&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)&lt;/p&gt;&lt;p&gt;DEVICE=eth0&lt;/p&gt;&lt;p&gt;BOOTPROTO=Dhcp&lt;/p&gt;&lt;p&gt;IPADDR=192.168.0.10&lt;/p&gt;&lt;p&gt;NETMASK=255.255.255.0&lt;/p&gt;&lt;p&gt;DHCPCLASS=&lt;/p&gt;&lt;p&gt;HWADDR=00:0C:29:16:72:7E&lt;/p&gt;&lt;p&gt;ONBOOT=yes&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;#退出VI命令&lt;/p&gt;&lt;p&gt;先按esc，然后输入 :q! ，存盘退出输入 :wq&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;#设置完IP后重新启动network&lt;/p&gt;&lt;p&gt;service network restart&lt;/p&gt;&lt;p&gt;设置完IP后SSH不上了...&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;##重装了下CentOS先备份ifcfg-eth0&lt;/p&gt;&lt;p&gt;# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)&lt;/p&gt;&lt;p&gt;DEVICE=eth0&lt;/p&gt;&lt;p&gt;BOOTPROTO=dhcp&lt;/p&gt;&lt;p&gt;DHCPCLASS=&lt;/p&gt;&lt;p&gt;HWADDR=00:0C:29:CC:23:12&lt;/p&gt;&lt;p&gt;ONBOOT=yes&lt;/p&gt;&lt;p&gt;还是不行,"回滚"了&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;#安装nginx成功&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/20120503160204587.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(16)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031602048668.png" alt="Image(16)" width="609" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;strong&gt;#复制目录&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;将 /etc/ 目录下的所有内容复制到 /tmp。&lt;/p&gt;&lt;p&gt;[root@linux tmp]# cp /etc/ /tmp&lt;/p&gt;&lt;p&gt;#删除目录&lt;/p&gt;&lt;p&gt;rm -r /usr/local/nginx&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;strong&gt;#ldd&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;[root@bogon nginx]# ldd $(which /opt/nginx/sbin/nginx)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; linux-vdso.so.1 =&amp;gt;&amp;nbsp; (0x00007ffff01fc000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; libcrypt.so.1 =&amp;gt; /lib64/libcrypt.so.1 (0x00002ac15257f000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; libpcre.so.1 =&amp;gt; not found&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; libc.so.6 =&amp;gt; /lib64/libc.so.6 (0x00002ac1527b7000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /lib64/ld-linux-x86-64.so.2 (0x00002ac152362000)&lt;/p&gt;&lt;p&gt;[root@bogon nginx]#&lt;/p&gt;&lt;p&gt;LDD是什么命令?&lt;/p&gt;&lt;p&gt;NGINX启动时提示错误：&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/local/nginx/sbin/nginx -t&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory&lt;/p&gt;&lt;p&gt;ldd $(which /usr/local/nginx/sbin/nginx)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; linux-vdso.so.1 =&amp;gt; (0x00007fff48ff0000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libcrypt.so.1 =&amp;gt; /lib64/libcrypt.so.1 (0x0000003065800000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libpcre.so.1 =&amp;gt; not found&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libssl.so.6 =&amp;gt; /lib64/libssl.so.6 (0x0000003067000000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libcrypto.so.6 =&amp;gt; /lib64/libcrypto.so.6 (0x0000003066400000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libdl.so.2 =&amp;gt; /lib64/libdl.so.2 (0x0000003063000000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libz.so.1 =&amp;gt; /lib64/libz.so.1 (0x0000003063c00000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libc.so.6 =&amp;gt; /lib64/libc.so.6 (0x0000003062c00000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libgssapi_krb5.so.2 =&amp;gt; /usr/lib64/libgssapi_krb5.so.2 (0x0000003066c00000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libkrb5.so.3 =&amp;gt; /usr/lib64/libkrb5.so.3 (0x0000003069c00000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libcom_err.so.2 =&amp;gt; /lib64/libcom_err.so.2 (0x0000003068800000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libk5crypto.so.3 =&amp;gt; /usr/lib64/libk5crypto.so.3 (0x0000003069000000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /lib64/ld-linux-x86-64.so.2 (0x0000003062800000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libkrb5support.so.0 =&amp;gt; /usr/lib64/libkrb5support.so.0 (0x000000306a800000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libkeyutils.so.1 =&amp;gt; /lib64/libkeyutils.so.1 (0x0000003067c00000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libresolv.so.2 =&amp;gt; /lib64/libresolv.so.2 (0x0000003068400000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libselinux.so.1 =&amp;gt; /lib64/libselinux.so.1 (0x0000003064400000)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; libsepol.so.1 =&amp;gt; /lib64/libsepol.so.1 (0x0000003064000000)&lt;/p&gt;&lt;p&gt;解决方法：&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ln -s /usr/local/lib/libpcre.so.1 /lib64&lt;/p&gt;&lt;p&gt;32位系统则：&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ln -s /usr/local/lib/libpcre.so.1 /lib&lt;/p&gt;&lt;p&gt;注：&lt;/p&gt;&lt;p&gt;/usr/local/lib/libpcre.so.1 为prce安装后的文件地址&lt;/p&gt;&lt;p&gt;低版本prce对应的libpcre.so.1 为libpcre.so.0&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031602054798.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(17)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031602059291.png" alt="Image(17)" width="633" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;OK终于搞定了&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031602069880.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Screenshot-Welcome to nginx! - Mozilla Firefox" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031602063294.png" alt="Screenshot-Welcome to nginx! - Mozilla Firefox" width="635" height="432" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2480739.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2012/05/03/linux-3.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/kkun/archive/2012/05/03/linux-2.html</id><title type="text">Linux学习笔记二</title><summary type="text">Linux学习区分大小写啊rpm -ivh mysql55231.rpm说找不到文件或目录输入rpm -ivh MySQL55231.rpm打印下图...开始安装了安装完事儿了如上所述,要求改密码,提示找不到文件或者目录[root@bogon file]# /usr/bin/mysqladmin -u root password '******' bash: /usr/bin/mysqladmin: No such file or directory [root@bogon file]#</summary><published>2012-05-03T08:01:00Z</published><updated>2012-05-03T08:01:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2012/05/03/linux-2.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2012/05/03/linux-2.html"/><content type="html">&lt;p&gt;Linux学习&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;区分大小写啊&lt;/p&gt;&lt;p&gt;rpm -ivh mysql55231.rpm说找不到文件或目录&lt;/p&gt;&lt;p&gt;输入&lt;/p&gt;&lt;p&gt;rpm -ivh MySQL55231.rpm打印下图...开始安装了&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031601175568.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(13)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031601173649.png" alt="Image(13)" width="666" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031601173682.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(14)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031601187860.png" alt="Image(14)" width="666" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;安装完事儿了&lt;/p&gt;&lt;p&gt;如上所述,要求改密码,提示找不到文件或者目录&lt;/p&gt;&lt;p&gt;[root@bogon file]# /usr/bin/mysqladmin -u root password '******' &lt;br /&gt;bash: /usr/bin/mysqladmin: No such file or directory    &lt;br /&gt;[root@bogon file]# &lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/20120503160118717.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(15)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031601182386.png" alt="Image(15)" width="666" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2480738.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2012/05/03/linux-2.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/kkun/archive/2012/05/03/linux-1.html</id><title type="text">Linux学习笔记一</title><summary type="text">Linux命令Ctrl + Alt + F1切换至命令行窗口Alt + F7切换至图形界面#1没有找到ifconfig命令,使用su切换至管理员帐号,使用/sbin/ifconfig命令则打印出上述界面#2 SSH至CentOS先是查看SSH是否在运行,命令/etc/init.d/sshd status回车后打印下图PING通了虚拟机了要想SSH至CENTOS还要WIN7下的工具,SSH Secure Shell Client 3.2.9下载地址 http://www.onlinedown.net/soft/20089.htm安装完之后顺序SSH,如图所示#3 安装NGINXhttp://ba</summary><published>2012-05-03T08:00:00Z</published><updated>2012-05-03T08:00:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2012/05/03/linux-1.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2012/05/03/linux-1.html"/><content type="html">&lt;p&gt;Linux命令&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;Ctrl + Alt + F1切换至命令行窗口&lt;/p&gt;&lt;p&gt;Alt + F7切换至图形界面&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600299088.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(3)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600296297.png" alt="Image(3)" width="724" height="404" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;#1没有找到ifconfig命令,使用su切换至管理员帐号,使用/sbin/ifconfig命令则打印出上述界面&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;#2 SSH至CentOS&lt;/p&gt;&lt;p&gt;先是查看SSH是否在运行,命令/etc/init.d/sshd status回车后打印下图&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600298282.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(4)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/20120503160030267.png" alt="Image(4)" width="724" height="404" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;PING通了虚拟机了&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/20120503160031399.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(5)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600333105.png" alt="Image(5)" width="1370" height="772" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;要想SSH至CENTOS还要WIN7下的工具,SSH Secure Shell Client 3.2.9&lt;/p&gt;&lt;p&gt;下载地址 &lt;a href="http://www.onlinedown.net/soft/20089.htm"&gt;http://www.onlinedown.net/soft/20089.htm&lt;/a&gt;&lt;/p&gt;&lt;p&gt;安装完之后顺序SSH,如图所示&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600336203.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(6)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/20120503160034696.png" alt="Image(6)" width="609" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;#3 安装NGINX&lt;/p&gt;&lt;p&gt;&lt;a href="http://baike.baidu.com/view/926025.htm"&gt;http://baike.baidu.com/view/926025.htm&lt;/a&gt;&lt;/p&gt;&lt;p&gt;nginx各版本下载&lt;/p&gt;&lt;p&gt;&lt;a href="http://nginx.org/en/download.html"&gt;http://nginx.org/en/download.html&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm"&gt;http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;#4 命令行如何下载文件&lt;/p&gt;&lt;p&gt;man命令 查看命令的帮助&lt;/p&gt;&lt;p&gt;man help&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600343237.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(7)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600345778.png" alt="Image(7)" width="609" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;找到下载命令 wget&lt;/p&gt;&lt;p&gt;man wget&lt;/p&gt;&lt;p&gt;在执行上述命令之前需要先输入Q以退出man命令...真没想到,可见在man命令执行后还可以模拟一些命令或者其它操作,不然怎么会不默认退出嘞?为了抓屏方便还要暂时再先学另外一个命令,如何清屏?答案是clear命令,哦耶!&lt;/p&gt;&lt;p&gt;执行命令&lt;/p&gt;&lt;p&gt;wget &lt;a href="http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm"&gt;http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm&lt;/a&gt;&lt;/p&gt;&lt;p&gt;打印下图:发现连不上主机,原因是该CentOS无法上网!&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/20120503160035272.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(8)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600356401.png" alt="Image(8)" width="609" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;所以只好在WIN7下下载好文件再上传至CentOS&lt;/p&gt;&lt;p&gt;下载简单,如何上传文件嘞?还好我们的SSH Secure Shell原生的支持了这个功能!&lt;/p&gt;&lt;p&gt;Window-&amp;gt;New File Transfer打开类似一个FTP的工具,如下图&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600368942.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(9)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031600365944.png" alt="Image(9)" width="609" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;然后直接上传就好了&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;#安装程序&lt;/p&gt;&lt;p&gt;rpm -i nginx.rpm报错,如下,不急,吃完饭再搞&lt;/p&gt;&lt;p&gt;[zhangbaokun@bogon file]$ rpm -i nginx.rpm &lt;br /&gt;warning: nginx.rpm: Header V3 RSA/SHA1 signature: NOKEY, key ID 7bd9bf62    &lt;br /&gt;error: can't create transaction lock on /var/lib/rpm/__db.000    &lt;br /&gt;[zhangbaokun@bogon file]$ &lt;/p&gt;&lt;p&gt;使用rpm -ivh file/nginx.rpm安装成功,如下图所示&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031559407525.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(10)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/2012050315594166.png" alt="Image(10)" width="609" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;再次执行命令&lt;/p&gt;&lt;p&gt;rpm -ivh file/nginx.rpm时提示already installed&lt;/p&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031559412607.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(11)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031559418737.png" alt="Image(11)" width="609" height="512" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031559429642.png"&gt;&lt;img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="Image(12)" src="http://images.cnblogs.com/cnblogs_com/kkun/201205/201205031559429675.png" alt="Image(12)" width="644" height="364" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;hr /&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2480736.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2012/05/03/linux-1.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/kkun/archive/2012/04/25/2470166.html</id><title type="text">What Is Cocoa?</title><summary type="text">Cocoa is an application environment for both the Mac OS X operating system and iOS, the operating system used on Multi-Touch devices such as iPhone, iPad, and iPod touch. It consists of a suite of obj...</summary><published>2012-04-25T09:30:00Z</published><updated>2012-04-25T09:30:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2012/04/25/2470166.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2012/04/25/2470166.html"/><content type="html">&lt;p&gt;Cocoa is an application environment for both the Mac OS X operating system and iOS, the operating system used on Multi-Touch devices such as iPhone, iPad, and iPod touch. It consists of a suite of object-oriented software libraries, a runtime system, and an integrated development environment.&lt;/p&gt;  &lt;p&gt;This chapter expands on this definition, describing the purpose, capabilities, and components of Cocoa on both platforms. Reading this functional description of Cocoa is an essential first step for a developer trying to understand Cocoa.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW27"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Cocoa Environment&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Cocoa is a set of object-oriented frameworks that provides a runtime environment for applications running in Mac OS X and iOS. Cocoa is the preeminent application environment for Mac OS X and the &lt;em&gt;only&lt;/em&gt;application environment for iOS. (Carbon is an alternative environment in Mac OS X, but it is a compatibility framework with procedural programmatic interfaces intended to support existing Mac OS X code bases.) Most of the applications you see in Mac OS X and iOS, including Mail and Safari, are Cocoa applications. An integrated development environment called Xcode supports application development for both platforms. The combination of this development environment and Cocoa makes it easy to create a well-factored, full-featured application.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW28"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Introducing Cocoa&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As with all application environments, Cocoa presents two faces; it has a runtime aspect and a development aspect. In its runtime aspect, Cocoa applications present the user interface and are tightly integrated with the other visible components of the operating system; in Mac OS X, these include the Finder, the Dock, and other applications from all environments.&lt;/p&gt;  &lt;p&gt;But it is the development aspect that is the more interesting one to programmers. Cocoa is an integrated suite of object-oriented software components—classes—that enables you to rapidly create robust, full-featured Mac OS X and iOS applications. These classes are reusable and adaptable software building blocks; you can use them as-is or extend them for your specific requirements. Cocoa classes exist for just about every conceivable development necessity, from user-interface objects to data formatting. Where a development need hasn’t been anticipated, you can easily create a subclass of an existing class that answers that need.&lt;/p&gt;  &lt;p&gt;Cocoa has one of the most distinguished pedigrees of any object-oriented development environment. From its introduction as NeXTSTEP in 1989 to the present day, it has been continually refined and tested (see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW12"&gt;“A Bit of History”&lt;/a&gt;). Its elegant and powerful design is ideally suited for the rapid development of software of all kinds, not only applications but command-line tools, plug-ins, and various types of bundles. Cocoa gives your application much of its behavior and appearance “for free,” freeing up more of your time to work on those features that are distinctive. (For details on what Cocoa offers, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW6"&gt;“Features of a Cocoa Application.”&lt;/a&gt;)&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW58"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;iOS Note:&lt;/strong&gt; Cocoa for iOS supports only application development and not development of any other kind of executable.&lt;/p&gt;  &lt;p&gt;You can use several &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_661"&gt;&lt;/a&gt;programming languages when developing Cocoa software, but the essential, required language is &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_662"&gt;&lt;/a&gt;Objective-C. Objective-C is a superset of &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_663"&gt;&lt;/a&gt;ANSI C that has been extended with certain syntactical and semantic features (derived from Smalltalk) to support object-oriented programming. The few added conventions are easy to learn and use. Because Objective-C rests on a foundation of ANSI C, you can freely intermix straight C code with Objective-C code. Moreover, your code can call functions defined in non-Cocoa programmatic interfaces, such as the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_664"&gt;&lt;/a&gt;BSD library interfaces in&lt;code&gt;/usr/include&lt;/code&gt;. You can even mix &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_665"&gt;&lt;/a&gt;C++ code with your Cocoa code and link the compiled code into the same executable.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW59"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Mac OS X Note:&lt;/strong&gt; In Mac OS X, you can also program in Cocoa using scripting bridges such as&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_666"&gt;&lt;/a&gt;PyObjC (the Python–Objective-C bridge) and &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_667"&gt;&lt;/a&gt;RubyCocoa (the Ruby–Cocoa bridge). Both bridged languages let you write Cocoa applications in the respective scripting languages, &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_668"&gt;&lt;/a&gt;Python and &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_669"&gt;&lt;/a&gt;Ruby. Both of these are interpreted, interactive, and object-oriented programming languages that make it possible for Python or Ruby objects to send messages to Objective-C objects as if they were Python or Ruby objects, and also for Objective-C objects to send messages to Python or Ruby objects. For more information, see &lt;em&gt;Ruby and Python Programming Topics for Mac OS X&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;The most important Cocoa class libraries come packaged in two core frameworks for each platform:&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_670"&gt;&lt;/a&gt;Foundation and &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_671"&gt;&lt;/a&gt;AppKit for Mac OS X, and Foundation and &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_672"&gt;&lt;/a&gt;UIKit for iOS. As with all frameworks, these contain not only a dynamically sharable library (or sometimes several versions of libraries required for backward compatibility), but header files, API documentation, and related resources. The pairing of Foundation with AppKit or UIKit reflects the division of the Cocoa programmatic interfaces into those classes that are not related to a graphical user interface and those that are. For each platform, its two core frameworks are essential to any Cocoa project whose end product is an application. Both platforms additionally support the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_673"&gt;&lt;/a&gt;Core Data framework, which is as important and useful as the core frameworks.&lt;/p&gt;  &lt;p&gt;Mac OS X also ships with several other frameworks that publish Cocoa programmatic interfaces, such as the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_674"&gt;&lt;/a&gt;WebKit and &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_675"&gt;&lt;/a&gt;Address Book frameworks; more Cocoa frameworks will be added to the operating system over time. See &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW10"&gt;“The Cocoa Frameworks”&lt;/a&gt; for further information.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW21"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;How Cocoa Fits into Mac OS X&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Architecturally, Mac OS X is a series of software layers going from the foundation of Darwin to the various application frameworks and the user experience they support. The intervening layers represent the system software largely (but not entirely) contained in the two major umbrella frameworks, Core Services and Application Services. A component at one layer generally has dependencies on the layer beneath it. Figure 1-1 situates Cocoa in this &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_676"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_677"&gt;&lt;/a&gt;architectural setting.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW5"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-1&lt;/strong&gt;&amp;#160; Cocoa in the architecture of Mac OS X&lt;img style="display: inline; float: right" alt="" align="right" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/osx_architecture.jpg" width="538" height="344" /&gt;&lt;/p&gt;  &lt;p&gt;For example, the system component that is largely responsible for rendering the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_678"&gt;&lt;/a&gt;Aqua user interface,&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_679"&gt;&lt;/a&gt;Quartz (implemented in the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_680"&gt;&lt;/a&gt;Core Graphics framework), is part of the Application Services layer. And at the base of the architectural stack is Darwin; everything in Mac OS X, including Cocoa, ultimately depends on Darwin to function.&lt;/p&gt;  &lt;p&gt;In Mac OS X, Cocoa has two &lt;em&gt;core&lt;/em&gt; Objective-C frameworks that are essential to application development for Mac OS X:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;AppKit.&lt;/strong&gt; AppKit, one of the application frameworks, provides the objects an application displays in its user interface and defines the structure for application behavior, including event handling and drawing. For a description of AppKit, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW25"&gt;“AppKit (Mac OS X).”&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Foundation.&lt;/strong&gt; This framework, in the Core Services layer, defines the basic behavior of objects, establishes mechanisms for their management, and provides objects for primitive data types, collections, and operating-system services. Foundation is essentially an object-oriented version of the Core Foundation framework; see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW20"&gt;“Foundation”&lt;/a&gt; for a discussion of the Foundation framework.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;AppKit has close, direct dependences on Foundation, which functionally is in the Core Services layer. If you look closer, at individual, or groups, of Cocoa classes and at particular frameworks, you begin to see where Cocoa either has specific dependencies on other parts of Mac OS X or where it exposes underlying technology with its interfaces. Some major underlying frameworks on which Cocoa depends or which it exposes through its classes and methods are Core Foundation, Carbon Core, Core Graphics (Quartz), and Launch Services:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_681"&gt;&lt;/a&gt;Core Foundation&lt;/strong&gt;. Many classes of the Foundation framework are based on equivalent Core Foundation opaque types. This close relationship is what makes “toll-free bridging”—cast-conversion between compatible Core Foundation and Foundation types—possible. Some of the implementation of Core Foundation, in turn, is based on the BSD part of the Darwin layer.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_682"&gt;&lt;/a&gt;Carbon Core&lt;/strong&gt;. AppKit and Foundation tap into the Carbon Core framework for some of the system services it provides. For example, Carbon Core has the File Manager, which Cocoa uses for conversions between various file-system representations.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_683"&gt;&lt;/a&gt;Core Graphics&lt;/strong&gt;. The Cocoa drawing and imaging classes are (quite naturally) closely based on the Core Graphics framework, which implements Quartz and the window server.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_684"&gt;&lt;/a&gt;Launch Services&lt;/strong&gt;. The &lt;code&gt;NSWorkspace&lt;/code&gt; class exposes the underlying capabilities of Launch Services. Cocoa also uses the application-registration feature of Launch Services to get the icons associated with applications and documents.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW60"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The intent of this architectural overview is not to itemize every relationship that Cocoa has to other parts of Mac OS X. Instead, it surveys the more interesting ones in order to give you a general idea of the architectural context of the framework.&lt;/p&gt;  &lt;p&gt;Apple has carefully designed Cocoa so that some of its programmatic interfaces give access to the capabilities of underlying technologies that applications typically need. But if you require some capability that is not exposed through the programmatic interfaces of Cocoa, or if you need some finer control of what happens in your application, you may be able to use an underlying framework directly. (A prime example is Core Graphics; by calling its functions or those of &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_685"&gt;&lt;/a&gt;OpenGL, your code can draw more complex and nuanced images than is possible with the Cocoa drawing methods.) Fortunately, using these lower-level frameworks is not a problem because the programmatic interfaces of most dependent frameworks are written in standard ANSI C, of which Objective-C language is a superset.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW61"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Further Reading:&lt;/strong&gt; &lt;em&gt;Mac OS X Technology Overview&lt;/em&gt; gives an overview of the frameworks, services, technologies, and other components of Mac OS X. &lt;em&gt;Mac OS X Human Interface Guidelines&lt;/em&gt; specifies how the Aqua human interface should appear and behave.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW29"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;How Cocoa Fits into iOS&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The application-framework layer of iOS is called Cocoa Touch. Although the iOS infrastructure on which Cocoa Touch depends is similar to that for Cocoa in Mac OS X, there are some significant differences. Compare Figure 1-2, which depicts the architectural setting of iOS, to the diagram in &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW5"&gt;Figure 1-1&lt;/a&gt;. The iOS diagram also shows the software supporting its platform as a series of layers going from a Core OS foundation to a set of application frameworks, the most critical (for applications) being the UIKit framework. As in the Mac OS X diagram, the iOS diagram has middle layers consisting of core-services frameworks and graphics and media frameworks and libraries. Here also, a component at one layer often has dependencies on the layer beneath it.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW19"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-2&lt;/strong&gt;&amp;#160; Cocoa in the architecture of iOS&lt;img style="display: inline; float: right; margin-left: 0px; margin-right: 0px" alt="Cocoa in the architecture of Aspen" align="right" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/architecture_stack.jpg" width="499" height="186" /&gt;&lt;/p&gt;  &lt;p&gt;Generally, the system libraries and frameworks of iOS that ultimately support UIKit are a subset of the libraries and frameworks in Mac OS X. For example, there is no Carbon application environment in iOS, there is no command-line access (the BSD environment in Darwin), there are no printing frameworks and services, and QuickTime is absent from the platform. However, because of the nature of the devices supported by iOS, there are some frameworks, both public and private, that are specific to iOS.&lt;/p&gt;  &lt;p&gt;The following summarizes some of the frameworks found at each layer of the iOS stack, starting from the foundation layer.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Core OS.&lt;/strong&gt; This level contains the kernel, the file system, networking infrastructure, security, power management, and a number of device drivers. It also has the libSystem library, which supports the POSIX/BSD 4.4/C99 API specifications and includes system-level APIs for many services.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Core Services.&lt;/strong&gt; The frameworks in this layer provide core services, such as string manipulation, collection management, networking, URL utilities, contact management, and preferences. They also provide services based on hardware features of a device, such as the GPS, compass, accelerometer, and gyroscope. Examples of frameworks in this layer are Core Location, Core Motion, and System Configuration.&lt;/p&gt;      &lt;p&gt;This layer includes both Foundation and Core Foundation, frameworks that provide abstractions for common data types such as strings and collections. The Core Frameworks layer also contains Core Data, a framework for object graph management and object persistence.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Media.&lt;/strong&gt; The frameworks and services in this layer depend on the Core Services layer and provide graphical and multimedia services to the Cocoa Touch layer. They include Core Graphics, Core Text, OpenGL ES, Core Animation, AVFoundation, Core Audio, and video playback.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Cocoa Touch.&lt;/strong&gt; The frameworks in this layer directly support applications based in iOS. They include frameworks such as Game Kit, Map Kit, and iAd.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The Cocoa Touch layer and the Core Services layer each has an Objective-C framework that is especially important for developing applications for iOS. These are the &lt;em&gt;core&lt;/em&gt; Cocoa frameworks in iOS:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;UIKit.&lt;/strong&gt; This framework provides the objects an application displays in its user interface and defines the structure for application behavior, including event handling and drawing. For a description of UIKit, see&lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW22"&gt;“UIKit (iOS).”&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Foundation.&lt;/strong&gt; This framework defines the basic behavior of objects, establishes mechanisms for their management, and provides objects for primitive data types, collections, and operating-system services. Foundation is essentially an object-oriented version of the Core Foundation framework; see&lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW20"&gt;“Foundation”&lt;/a&gt; for a discussion of the Foundation framework.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW83"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt; This document uses “Cocoa” generically when referring to things that are common between the platforms. When it is necessary to say something specific about Cocoa on a given platform, it uses a phrase such as “Cocoa in Mac OS X.”&lt;/p&gt;  &lt;p&gt;As with Cocoa in Mac OS X, the programmatic interfaces of Cocoa in iOS give your applications access to the capabilities of underlying technologies. Usually there is a Foundation or UIKit method or function that can tap into a lower-level framework to do what you want. But, as with Cocoa in Mac OS X, if you require some capability that is not exposed through a Cocoa API, or if you need some finer control of what happens in your application, you may choose to use an underlying framework directly. For example, UIKit uses the WebKit to draw text and publishes some methods for drawing text; however, you may decide to use Core Text to draw text because that gives you the control you need for text layout and font management. Again, using these lower-level frameworks is not a problem because the programmatic interfaces of most dependent frameworks are written in standard ANSI C, of which the Objective-C language is a superset.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW62"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Further Reading:&lt;/strong&gt; To learn more about the frameworks, services, and other aspects of the iOS platform, see &lt;em&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/Miscellaneous/Conceptual/iPhoneOSTechOverview/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007898"&gt;iOS Technology Overview&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW6"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Features of a Cocoa Application&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_686"&gt;&lt;/a&gt;In Mac OS X it is possible to create a Cocoa application without adding a single line of code. You make a new Cocoa application project using Xcode and then build the project. That’s it. Of course, this application won’t do much, or at least much that’s interesting. But this extremely simple application still launches when double-clicked, displays its icon in the Dock, displays its menus and window (titled “Window”), hides itself on command, behaves nicely with other running applications, and quits on command. You can move, resize, minimize, and close the window. You can even print the emptiness contained by the window.&lt;/p&gt;  &lt;p&gt;You can do the same with an iOS application. Create a project in Xcode using one of the project templates, immediately build it, and run it in the iOS Simulator. The application quits when you click the Home button (or press it on a device). To launch the application, click its icon in Simulator. It may even have additional behaviors; for example, with an application made from the Utility Application template, the initial view &amp;quot;flips” to a second view when you click or tap the information (“i”) icon.&lt;/p&gt;  &lt;p&gt;Imagine what you could do with a little code.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW63"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;iOS Note:&lt;/strong&gt; The features and behavior of an application running in iOS are considerably different from a Mac OS X application, largely because it runs in a more constrained environment. For discussions of application capabilities and constraints in iOS, see &lt;em&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007072"&gt;iOS App Programming Guide&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;In terms of programming effort, Cocoa gives you, the developer, much that is free and much that is low-cost. Of course, to become a productive Cocoa developer means becoming familiar with possibly new concepts, design patterns, programming interfaces, and development tools, and this effort is not negligible. But familiarity yields greater productivity. Programming becomes largely an exercise in assembling the programmatic components that Cocoa provides along with the custom objects and code that define your program’s particular logic, then fitting everything together.&lt;/p&gt;  &lt;p&gt;What follows is a short list of how Cocoa adds value to an application with only a little (and sometimes no) effort on your part:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Basic application framework&lt;/strong&gt;—Cocoa provides the infrastructure for event-driven behavior and for management of applications, windows, and (in the case of Mac OS X) workspaces. In most cases, you won’t have to handle events directly or send any drawing commands to a rendering library.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;User-interface objects&lt;/strong&gt;—Cocoa offers a rich collection of ready-made objects for your application’s user interface. Most of these objects are available in the library of Interface Builder, a development application for creating user interfaces; you simply drag an object from the library onto the surface of your interface, configure its attributes, and connect it to other objects. (And, of course, you can always instantiate, configure, and connect these objects programmatically.)&lt;/p&gt;      &lt;p&gt;Here is a sampling of Cocoa &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_687"&gt;&lt;/a&gt;user-interface objects:&lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;p&gt;Windows&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Text fields&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Image views&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Date pickers&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Sheets and dialogs&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Segmented controls&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Table views&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Progress indicators&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Buttons&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Sliders&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Radio buttons (Mac OS X)&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Color wells (Mac OS X)&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Drawers (Mac OS X)&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Page controls (iOS)&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Navigation bars (iOS)&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;Switch controls (iOS)&lt;/p&gt;       &lt;/li&gt;     &lt;/ul&gt;      &lt;p&gt;Cocoa in Mac OS X also features technologies that support user interfaces, including those that promote accessibility, perform validation, and facilitate the connections between objects in the user interface and custom objects.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Drawing and imaging&lt;/strong&gt;—Cocoa enables efficient &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_688"&gt;&lt;/a&gt;drawing of custom views with a framework for locking graphical focus and marking views (or portions of views) as “dirty.” Cocoa includes programmatic tools for drawing Bezier paths, performing affine transforms, compositing images, generating PDF content, and (in Mac OS X) creating various representations of images.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;System interaction&lt;/strong&gt;—In Mac OS X, Cocoa gives your application ways to interact with (and use the services of) the file system, the workspace, and other applications. In iOS, Cocoa lets you pass URLs to applications to have them handle the referenced resource (for example, email or websites); it also provides support for managing user interactions with files in the local system and for scheduling local notifications.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_689"&gt;&lt;/a&gt;Performance&lt;/strong&gt;—To enhance the performance of your application, Cocoa provides programmatic support for concurrency, multithreading, lazy loading of resources, memory management, and run-loop manipulation.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Internationalization&lt;/strong&gt;—Cocoa provides a rich architecture for &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_690"&gt;&lt;/a&gt;internationalizing applications, making it possible for you to support localized resources such as text, images, and even user interfaces. The Cocoa approach is based on users’ lists of preferred languages and puts localized resources in bundles of the application. Based on the settings it finds, Cocoa automatically selects the localized resource that best matches the user’s preferences. It also provides tools and programmatic interfaces for generating and accessing localized strings. Moreover, text manipulation in Cocoa is based on Unicode by default, and is thus an asset for internationalization.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Text&lt;/strong&gt;—In Mac OS X, Cocoa provides a sophisticated &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_691"&gt;&lt;/a&gt;text system that allows you to do things with text ranging from the simple (for example, displaying a text view with editable text) to the more complex, such as controlling kerning and ligatures, spell checking, regular expressions, and embedding images in text. Although Cocoa in iOS has no native text system (it uses WebKit for string drawing) and its text capabilities are more limited, it still includes support for spellchecking, regular expressions, and interacting with the text input system.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_692"&gt;&lt;/a&gt;Preferences&lt;/strong&gt;—The &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_693"&gt;&lt;/a&gt;user defaults system is based on a systemwide database in which you can store global and application-specific preferences. The procedure for specifying application preferences is different for Mac OS X and iOS.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_694"&gt;&lt;/a&gt;Networking&lt;/strong&gt;—Cocoa also offers programmatic interfaces for communicating with servers using standard Internet protocols, communicating via sockets, and taking advantage of Bonjour, which lets your application publish and discover services on an IP network.&lt;/p&gt;      &lt;p&gt;In Mac OS X, Cocoa includes a &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_695"&gt;&lt;/a&gt;distributed objects architecture that allows one Cocoa process to communicate with another process on the same computer or on a different one. In iOS, Cocoa supports the capability for servers to push notifications to devices for applications registered to received such notifications.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_696"&gt;&lt;/a&gt;Printing&lt;/strong&gt;—Cocoa on both platforms supports printing. Their printing architecture lets you print images, documents, and other application content along a range of control and sophistication. At the simplest level, you can print the contents of any view or print an image or PDF document with just a little code. At a more complicated level, you can define the content and format of printed content, control how a print job is performed, and do pagination. In Mac OS X, you can add an accessory view to the Print dialog.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_697"&gt;&lt;/a&gt;Undo management&lt;/strong&gt;—You can register user actions that occur with an undo manager, and it will take care of undoing them (and redoing them) when users choose the appropriate menu items. The manager maintains undo and redo operations on separate stacks.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_698"&gt;&lt;/a&gt;Multimedia&lt;/strong&gt;—Both platforms programmatically support video and audio. In Mac OS X, Cocoa offers support for QuickTime video.&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_699"&gt;&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Data exchange&lt;/strong&gt;—Cocoa simplifies the exchange of data within an application and between applications using the copy-paste model. In Mac OS X, Cocoa also supports drag-and-drop models and the sharing of application capabilities through the Services menu.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Cocoa in Mac OS X has a couple of other features:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_700"&gt;&lt;/a&gt;Document-based applications&lt;/strong&gt;—Cocoa specifies an &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_701"&gt;&lt;/a&gt;architecture for applications composed of a potentially unlimited number of documents, with each contained in its own window (a word processor, for example). Indeed, if you choose the “Document-based application” project type in Xcode, many of the components of this sort of application are created for you.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_702"&gt;&lt;/a&gt;Scripting&lt;/strong&gt;— Through &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_703"&gt;&lt;/a&gt;application scriptability information and a suite of supporting Cocoa classes, you can make your application scriptable; that is, it can respond to commands emitted by AppleScript scripts. Applications can also execute scripts or use individual Apple events to send commands to, and receive data from, other applications. As a result, every scriptable application can supply services to both users and other applications.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW30"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;The Development Environment&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You develop Cocoa software primarily by using the two developer applications, Xcode and Interface Builder. It is possible to develop Cocoa applications without using these applications at all. For example, you could write code using a text editor such as Emacs, build the application from the command line using makefiles, and debug the application from the command line using the &lt;code&gt;gdb&lt;/code&gt; debugger. But why would you want to give yourself so much grief?&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW65"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &amp;quot;Xcode” is sometimes used to refer to the complete suite of development tools and frameworks, and other times specifically to the application that allows you to manage projects, edit source code, and build executable code.&lt;/p&gt;  &lt;p&gt;The origins of Xcode and Interface Builder coincide with the origins of Cocoa itself, and consequently there is a high degree of compatibility between tools and frameworks. Together, Xcode and Interface Builder make it extraordinarily easy to design, manage, build, and debug Cocoa software projects.&lt;/p&gt;  &lt;p&gt;When you install the development tools and documentation, you may select the installation location. Traditionally that location has been &lt;code&gt;/Developer&lt;/code&gt;, but it can be anywhere in the file system you wish. To designate this installation location, the documentation uses &lt;code&gt;&amp;lt;Xcode&amp;gt;&lt;/code&gt;. Thus, the development applications are installed in &lt;code&gt;&amp;lt;Xcode&amp;gt;/Applications&lt;/code&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW31"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Platform SDKs&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Beginning with Xcode 3.1 and the introduction of iOS, when you create a software project you must choose a platform SDK. The SDK enables you to build an executable that is targeted for a particular release of Mac OS X or iOS.&lt;/p&gt;  &lt;p&gt;The platform SDK contains everything that is required for developing software for a given platform and operating-system release. A Mac OS X SDK consists of frameworks, libraries, header files, and system tools. The SDK for iOS has the same components, but includes a platform-specific compiler and other tools. There is also a separate SDK for iOS Simulator (see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW23"&gt;“The iOS Simulator Application”&lt;/a&gt;). All SDKs include build settings and project templates appropriate to their platform.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW66"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Further reading:&lt;/strong&gt; For more on platform SDKs, see &lt;em&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/cross_development/Introduction/Introduction.html#//apple_ref/doc/uid/10000163i"&gt;SDK Compatibility Guide&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW32"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Overview of Development Workflows&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Application development differs for Mac OS X and iOS, not only in the tools used but in the development workflow.&lt;/p&gt;  &lt;p&gt;In Mac OS X, the typical development workflow is the following:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;p&gt;In Xcode, create a project using a template from the Mac OS X SDK.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Write code and, using Interface Builder, construct your application’s user interface.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Define the targets and executable environment for your project.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Test and debug the application using the Xcode debugging facilities.&lt;/p&gt;      &lt;p&gt;As part of debugging, you can check the system logs in the Console window.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Measure application performance using one or more of the available performance tools.&lt;/p&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;For iOS development, the workflow when developing an application is a bit more complex. Before you can develop for iOS, you must register as a developer for the platform. Thereafter, building an application that’s ready to deploy requires that you go through the following steps:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;p&gt;Configure the remote device.&lt;/p&gt;      &lt;p&gt;This configuration results in the required tools, frameworks, and other components being installed on the device.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;In Xcode, create a project using a template from the iOS SDK.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Write code, and construct your application’s user interface.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Define the targets and executable environment for the project.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Build the application (locally).&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Test and debug the application, either in iOS Simulator or remotely in the device. (If remotely, your debug executable is downloaded to the device.)&lt;/p&gt;      &lt;p&gt;As you debug, you can check the system logs for the device in the Console window.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Measure application performance using one or more of the available performance tools.&lt;/p&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW67"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Further reading:&lt;/strong&gt; For more on the development workflow in iOS, see &lt;em&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/Xcode/Conceptual/ios_development_workflow/00-About_the_iOS_Application_Development_Workflow/introduction.html#//apple_ref/doc/uid/TP40007959"&gt;Tools Workflow Guide for iOS&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW33"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Xcode&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_704"&gt;&lt;/a&gt;Xcode is the engine that powers Apple’s integrated development environment (IDE) for Mac OS X and iOS. It is also an application that takes care of most project details from inception to deployment. It allows you to:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Create and manage projects, including specifying platforms, target requirements, dependencies, and build configurations.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Write source code in editors with features such as syntax coloring and automatic indenting.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Navigate and search through the components of a project, including header files and documentation.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Build the project.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Debug the project locally, in iOS Simulator, or remotely, in a graphical source-level debugger.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Xcode builds projects from source code written in C, C++, Objective-C, and Objective-C++. It generates executables of all types supported in Mac OS X, including command-line tools, frameworks, plug-ins, kernel extensions, bundles, and applications. (For iOS, only application executables are possible.) Xcode permits almost unlimited customization of build and debugging tools, executable packaging (including information property lists and localized bundles), build processes (including copy-file, script-file, and other build phases), and the user interface (including detached and multiview code editors). Xcode also supports several &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_705"&gt;&lt;/a&gt;source-code management systems—namely CVS, Subversion, and Perforce—allowing you to add files to a repository, commit changes, get updated versions, and compare versions.&lt;/p&gt;  &lt;p&gt;Figure 1-3 shows an example of a project in Xcode.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW2"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-3&lt;/strong&gt;&amp;#160; The TextEdit example project in Xcode&lt;img style="display: inline; float: right" alt="The TextEdit example project in Xcode" align="right" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/xcode.jpg" width="641" height="643" /&gt;&lt;/p&gt;  &lt;p&gt;Xcode is especially suited for Cocoa development. When you create a project, Xcode sets up your initial development environment using project templates corresponding to Cocoa project types: application, document-based application, Core Data application, tool, bundle, framework, and others. For compiling Cocoa software, Xcode gives you several options:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;GCC—The &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_706"&gt;&lt;/a&gt;GNU C compiler (&lt;code&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_707"&gt;&lt;/a&gt;gcc&lt;/code&gt;).&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_708"&gt;&lt;/a&gt;LLVM-GCC—A configuration where GCC is used as the front end for the LLVM (Low Level Virtual Machine) compiler. LLVM offers fast optimization times and high-quality code generation.&lt;/p&gt;      &lt;p&gt;This option is available only for projects built for Mac OS X v10.6 and later.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_709"&gt;&lt;/a&gt;Clang—A front end specifically designed for the LLVM compiler. Clang offers fast compile times and excellent diagnostics.&lt;/p&gt;      &lt;p&gt;This option is available only for projects built for Mac OS X v10.6 and later.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For details about these compiler options, see &lt;em&gt;Xcode Build System Guide&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;For debugging software, Xcode offers the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_710"&gt;&lt;/a&gt;GNU source-level debugger (&lt;code&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_711"&gt;&lt;/a&gt;gdb&lt;/code&gt;) and the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_712"&gt;&lt;/a&gt;Clang Static Analyzer. The Clang Static Analyzer consists of a framework for source-code analysis and a standalone tool that finds bugs in C and Objective-C programs. See &lt;a href="http://clang-analyzer.llvm.org/"&gt;http://clang-analyzer.llvm.org/&lt;/a&gt; for more information.&lt;/p&gt;  &lt;p&gt;Xcode is well integrated with the other major development application, Interface Builder. See “Interface Builder” for details.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW68"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Further Reading:&lt;/strong&gt; &lt;em&gt;A Tour of Xcode&lt;/em&gt; gives an overview of Xcode and provides links to additional development-tools documentation.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW18"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Interface Builder&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The second major development application for Cocoa projects is &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_713"&gt;&lt;/a&gt;Interface Builder. As its name suggests, Interface Builder is a graphical tool for creating user interfaces. Interface Builder has been around almost since the inception of Cocoa as &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_714"&gt;&lt;/a&gt;NeXTSTEP. Not surprisingly, its integration with Cocoa is airtight.&lt;/p&gt;  &lt;p&gt;Interface Builder is centered around four main design elements:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Nib files&lt;/strong&gt;. A &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_715"&gt;&lt;/a&gt;nib file is a file wrapper (an opaque directory) that contains the objects appearing on a user interface in an archived form. Essentially, the archive is an object graph that contains information about each object, including its size and location, about the connections between objects, and about proxy references for custom classes. When you create and save a user interface in Interface Builder, all information necessary to re-create the interface is stored in the nib file.&lt;/p&gt;      &lt;p&gt;Nib files offer a way to easily localize user interfaces. Interface Builder stores a nib file in a localized directory inside a Cocoa project; when that project is built, the nib file is copied to a corresponding localized directory in the created bundle.&lt;/p&gt;      &lt;p&gt;Interface Builder presents the contents of a nib file in a &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_716"&gt;&lt;/a&gt;nib document window (also called a &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_717"&gt;&lt;/a&gt;&lt;em&gt;nib file window&lt;/em&gt;). The nib document window gives you access to the important objects in a nib file, especially top-level objects such as windows, menus, and controller objects that have no parent in their object graph. (Controller objects mediate between user-interface objects and the model objects that represent application data; they also provide overall management for an application.)&lt;/p&gt;      &lt;p&gt;Figure 1-4 shows a nib file opened in Interface Builder and displayed in a nib document window, along with supporting windows.&lt;/p&gt;      &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW4"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-4&lt;/strong&gt;&amp;#160; The TextEdit Document Properties window in Interface Builder&lt;img alt="The TextEdit Document Properties window in Interface Builder" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/ib3_2.jpg" width="566" height="662" /&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Object library&lt;/strong&gt;. The Library window of Interface Builder &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_718"&gt;&lt;/a&gt;contains objects that you can place on a user interface. They range from typical UI objects—for example, windows, controls, menus, text views, and outline views—to controller objects, custom view objects, and framework-specific objects, such as the Image Kit browser view. The Library groups the objects by categories and lets you browse through them and search for specific objects. When an object is dragged from the Library to an interface, Interface Builder instantiates a default instance of that object. You can resize, configure, and connect the object to other objects using the inspector.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Inspector&lt;/strong&gt;. Interface Builder has the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_719"&gt;&lt;/a&gt;inspector, a window for configuring the objects of a user interface. The inspector has a number of selectable panes for setting the initial runtime configuration of objects (although size and some attributes can also be set by direct manipulation). The inspector in Figure 1-4shows the primary attributes for a text field; note that different collapsible sections of the pane reveal attributes at various levels of the inheritance hierarchy (text field, control, and view). In addition to primary attributes and size, the inspector features panes for animation effects, event handlers, and target-action connections between objects; for nib files in Mac OS X projects, there are additional panes for AppleScript and bindings.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Connections panel&lt;/strong&gt;. &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_720"&gt;&lt;/a&gt;The connections panel is a context-sensitive display that shows the current outlet and action connections for a selected object and lets you manage those connections. To get the connections panel to appear, Control-click the target object. Figure 1-5 shows what the connections panel looks like.&lt;/p&gt;      &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW17"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-5&lt;/strong&gt;&amp;#160; The Interface Builder connections panel&lt;img alt="The Interface Builder connections panel" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/outlets1.jpg" width="712" height="256" /&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Interface Builder uses blue lines that briefly appear to show the compliance of each positioned object, when moved or resized, to the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_721"&gt;&lt;/a&gt;Aqua human interface guidelines. This compliance includes recommended size, alignment, and position relative to other objects on the user interface and to the boundaries of the window.&lt;/p&gt;  &lt;p&gt;Interface Builder is tightly integrated with Xcode. It “knows” about the outlets, actions, and bindable properties of your custom classes. When you add, remove, or modify any of these things, Interface Builder detects those changes and updates its presentation of them.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW69"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Further Reading:&lt;/strong&gt; For further information on Interface Builder, see &lt;em&gt;Interface Builder User Guide&lt;/em&gt;. Also refer to &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-CH7-SW15"&gt;“Communicating with Objects”&lt;/a&gt; for overviews of outlets, the target-action mechanism, and the Cocoa bindings technology.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW23"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The iOS Simulator Application&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;For iOS projects, you can select iOS Simulator as the platform SDK for the project. When you build and run the project, Xcode runs Simulator, which presents your application as it would appear on the device (iPhone or iPad) and allows you to manipulate parts of the user interface. You can use Simulator to help you debug the application prior to loading it onto the device.&lt;/p&gt;  &lt;p&gt;You should always perform the final phase of debugging on the device. Simulator does not perfectly simulate the device. For example, you must use the mouse pointer instead of finger touches, and so manipulations of the interface requiring multiple fingers are not possible. In addition, Simulator does not use versions of the OpenGL framework that are specific to iOS, and it uses the Mac OS X versions of the Foundation, Core Foundation, and CFNetwork frameworks, as well as the Mac OS X version of libSystem.&lt;/p&gt;  &lt;p&gt;More importantly, you should not assume that the performance of your application on Simulator is the same as it would be on the device. Simulator is essentially running your iOS application as a &amp;quot;guest” Mac OS X application. As such, it has a 4 GB memory partition and swap space available to it as it runs on a processor that is more powerful than the one on the device.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW70"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Further reading:&lt;/strong&gt; For more on iOS Simulator, see &lt;em&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/Xcode/Conceptual/ios_development_workflow/00-About_the_iOS_Application_Development_Workflow/introduction.html#//apple_ref/doc/uid/TP40007959"&gt;Tools Workflow Guide for iOS&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW34"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Performance Applications and Tools&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Although Xcode and Interface Builder are the major tools you use to develop Cocoa applications, there are dozens of other tools at your disposal. Many of these tools are performance applications.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW35"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Instruments&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_722"&gt;&lt;/a&gt;Instruments is an application introduced in Xcode 3.0 that lets you run multiple performance-testing tools simultaneously and view the results in a timeline-based graphical presentation. It can show you CPU usage, disk reads and writes, memory statistics, thread activity, garbage collection, network statistics, directory and file usage, and other measurements—individually or in different combinations—in the form of graphs tied to time. This simultaneous presentation of instrumentation data helps you to discover the relationships between what is being measured. It also displays the specific data behind the graphs.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW71"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Further Reading:&lt;/strong&gt; See the &lt;em&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40004652"&gt;Instruments User Guide&lt;/a&gt;&lt;/em&gt; for complete information about the Instruments application.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW36"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-6&lt;/strong&gt;&amp;#160; The Instruments application&lt;img alt="The Instruments application" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/instruments_window.jpg" width="789" height="548" /&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW37"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Shark&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_723"&gt;&lt;/a&gt;Shark is a performance-analysis application that creates a time-based profile of your program’s execution; over a given period it traces function calls and graphs memory allocations. You can use Shark to track information for a single program or for the entire system, which in Mac OS X includes kernel components such as drivers and kernel extensions. Shark also monitors file-system calls, traces system calls and memory allocations, performs static analyses of your code, and gathers information about cache misses, page faults, and other system metrics. Shark supports the analysis of code written in C, Objective-C, C++, and other languages.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW38"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Other Performance Applications (Mac OS X)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Many &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_724"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_725"&gt;&lt;/a&gt;applications are used in measuring and analyzing aspects of a Mac OS X program’s performance. These applications are located in &lt;code&gt;&amp;lt;Xcode&amp;gt;/Applications/Performance Tools&lt;/code&gt;.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;BigTop&lt;/strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_726"&gt;&lt;/a&gt; graphs performance trends over time, providing a real-time display of memory usage, page faults, CPU usage, and other data.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_727"&gt;&lt;/a&gt;Spin Control&lt;/strong&gt; automatically samples unresponsive applications. You leave Spin Control running in the background while you launch and test your applications. If applications become unresponsive to the point where the spinning cursor appears, Spin Control automatically samples your application to gather information about what your application was doing during that time.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_728"&gt;&lt;/a&gt;MallocDebug&lt;/strong&gt; shows all currently allocated blocks of memory in your program, organized by the call stack at the time of allocation. At a glance you can see how much allocated memory your application consumes, where that memory was allocated from, and which functions allocated large amounts of memory. MallocDebug can also find allocated memory that is not referenced elsewhere in the program, thus helping you find leaks and track down exactly where the memory was allocated.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_729"&gt;&lt;/a&gt;QuartzDebug&lt;/strong&gt; is a tool to help you debug how your application displays itself. It is especially useful for applications that do significant amounts of drawing and imaging. QuartzDebug has several debugging options, including the following:&lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;p&gt;Auto-flush drawing, which flushes the contents of graphics contexts after each drawing operation&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;A mode that paints regions of the screen in yellow just before they’re updated&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;An option that takes a static snapshot of the systemwide window list, showing the owner of each window and how much memory each window consumes&lt;/p&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;For performance analysis, you can also use command-line tools such as:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;code&gt;top&lt;/code&gt;, which shows a periodically sampled set of statistics on currently running processes&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;code&gt;gprof&lt;/code&gt;, which produces an execution profile of a program&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;code&gt;fs_usage&lt;/code&gt;, which displays file-system access statistics&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Many other command-line tools for performance analysis and other development tasks are available. Some are located in &lt;code&gt;/usr/bin&lt;/code&gt; and &lt;code&gt;/usr/sbin&lt;/code&gt;, and some Apple-developed command-line tools are installed in &lt;code&gt;&amp;lt;Xcode&amp;gt;/Tools&lt;/code&gt;. For many of these tools you can consult their manual page for usage information. (To do this, either choose Help &amp;gt; Open man page in Xcode or type &lt;code&gt;man&lt;/code&gt; followed by the name of the tool in a Terminal shell.)&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW72"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Further Reading:&lt;/strong&gt; For more on the performance tools and applications you can use in Cocoa application development, as well as information on concepts, techniques, guidelines, and strategy related to performance, see &lt;em&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/Performance/Conceptual/PerformanceOverview/Introduction/Introduction.html#//apple_ref/doc/uid/TP40001410"&gt;Performance Overview&lt;/a&gt;&lt;/em&gt;. &lt;em&gt;Cocoa Performance Guidelines&lt;/em&gt; covers the performance guidelines for Cocoa.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW10"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Cocoa Frameworks&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_730"&gt;&lt;/a&gt;What makes a program a Cocoa program? It’s not really the language, because you can use a variety of languages in Cocoa development. It’s not the development tools, because you could create a Cocoa application from the command line (although that would be a complex, time-consuming task). No, what all Cocoa programs have in common—what makes them distinctive—is that they are composed of objects that inherit ultimately from the root class, &lt;code&gt;NSObject&lt;/code&gt;, and that are ultimately based upon the Objective-C runtime. This statement is also true of all Cocoa frameworks.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW74"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The statement about the root class needs to be qualified a bit. First, the Foundation framework supplies another root class, &lt;code&gt;NSProxy&lt;/code&gt;; however, &lt;code&gt;NSProxy&lt;/code&gt; is rarely used in Cocoa programming. Second, you could create your own root class, but this would be a lot of work (entailing the writing of code that interacts with the Objective-C runtime) and probably not worth your time.&lt;/p&gt;  &lt;p&gt;On any system there are many Cocoa frameworks, and Apple and third-party vendors are releasing more frameworks all the time. Despite this abundance of Cocoa frameworks, two of them stand out on each platform as core frameworks:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;In Mac OS X: Foundation and AppKit&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;In iOS: Foundation and UIKit&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The Foundation, AppKit, and UIKit frameworks are essential to Cocoa application development, and all other frameworks are secondary and elective. You cannot develop a Cocoa application for Mac OS X unless you link against (and use the classes of) the AppKit, and you cannot develop a Cocoa application for iOS unless you link against (and use the classes of) UIKit. Moreover, you cannot develop Cocoa software of any kind unless you link against and use the classes of the Foundation framework. (Linking against the right frameworks in Mac OS X happens automatically when you link against the Cocoa umbrella framework.) Classes, functions, data types, and constants in Foundation and the AppKit have a prefix of “NS”; classes, functions, data types, and constants in UIKit have a prefix of “UI”.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW75"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; In Mac OS X version 10.5 the Cocoa frameworks were ported to support 64-bit addressing. iOS also supports 64-bit addressing. As part of this effort, various general changes have been made to the Cocoa API, most significantly the introduction of the &lt;code&gt;NSInteger&lt;/code&gt; and &lt;code&gt;NSUInteger&lt;/code&gt; types (replacing &lt;code&gt;int&lt;/code&gt; and &lt;code&gt;unsigned int&lt;/code&gt; where appropriate) and the &lt;code&gt;CGFloat&lt;/code&gt; type (replacing most instances of &lt;code&gt;float&lt;/code&gt;). Most Cocoa applications have no immediate need to make the transition to 64-bit, but for those that do, porting tools and guidelines are available. &lt;em&gt;64-Bit Transition Guide for Cocoa&lt;/em&gt;discusses these matters in detail.&lt;/p&gt;  &lt;p&gt;The Cocoa frameworks handle many low-level tasks for you. For example, classes that store and manipulate integer and floating-point values automatically handle the endianness of those values for you.&lt;/p&gt;  &lt;p&gt;The following sections survey the features and classes of the three core Cocoa frameworks and briefly describe some of the secondary frameworks. Because each of these core frameworks has dozens of classes, the descriptions of the core frameworks categorize classes by their function. Although these categorizations have a strong logical basis, one can plausibly group classes in other ways.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW20"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Foundation&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_731"&gt;&lt;/a&gt;Foundation framework defines a base layer of classes that can be used for any type of Cocoa program. The criterion separating the classes in Foundation from those in the AppKit is the user interface. If an object doesn’t either appear in a user interface or isn’t &lt;em&gt;exclusively&lt;/em&gt; used to support a user interface, then its class belongs in Foundation. You can create Cocoa programs that use Foundation and no other framework; examples of these are command-line tools and Internet servers.&lt;/p&gt;  &lt;p&gt;The Foundation framework was designed with certain goals in mind:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Define basic object behavior and introduce consistent conventions for such things as &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_732"&gt;&lt;/a&gt;memory management, object mutability, and notifications.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Support internationalization and localization with (among other things) bundle technology and Unicode strings.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Support object persistence.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Support object distribution.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Provide some measure of operating-system independence to support portability.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Provide object wrappers or equivalents for programmatic primitives, such as numeric values, strings, and collections. It also provides utility classes for accessing underlying system entities and services, such as ports, threads, and file systems.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Cocoa applications, which by definition link either against the AppKit framework or UIKit framework, invariably must link against the Foundation framework as well. The class hierarchies share the same root class, &lt;code&gt;NSObject&lt;/code&gt;, and many if not most of the AppKit and UIKit methods and functions have Foundation objects as parameters or return values. Some Foundation classes may seem designed for applications—&lt;code&gt;NSUndoManager&lt;/code&gt; and &lt;code&gt;NSUserDefaults&lt;/code&gt;, to name two—but they are included in Foundation because there can be uses for them that do not involve a user interface.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW7"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Foundation Paradigms and Policies&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Foundation introduces several &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_733"&gt;&lt;/a&gt;paradigms and policies to Cocoa programming to ensure consistent behavior and expectations among the objects of a program in certain situations.:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Object retention and object disposal&lt;/strong&gt;. The Objective-C runtime and Foundation give Cocoa programs two ways to ensure that objects persist when they’re needed and are freed when they are no longer needed. &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_734"&gt;&lt;/a&gt;Garbage collection, which was introduced in Objective-C 2.0, automatically tracks and disposes of objects that your program no longer needs, thus freeing up memory. Foundation also still offers the traditional approach of &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_735"&gt;&lt;/a&gt;memory management. It institutes a policy of &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_736"&gt;&lt;/a&gt;object ownership that specifies that objects are responsible for releasing other objects that they have created, copied, or explicitly retained. &lt;code&gt;NSObject&lt;/code&gt; (class and protocol) defines methods for retaining and releasing objects. &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_737"&gt;&lt;/a&gt;Autorelease pools (defined in the &lt;code&gt;NSAutoreleasePool&lt;/code&gt; class) implement a delayed-release mechanism and enable Cocoa programs to have a consistent convention for returning objects for which the caller is not responsible. For more about garbage collection and explicit memory management, see&lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW39"&gt;“Object Retention and Disposal.”&lt;/a&gt;&lt;/p&gt;      &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW76"&gt;&lt;/a&gt;&lt;/p&gt;      &lt;p&gt;&lt;strong&gt;iOS Note:&lt;/strong&gt; Garbage collection is not available to applications running in iOS.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_738"&gt;&lt;/a&gt;Mutable class variants&lt;/strong&gt;. Many value and container classes in Foundation have a mutable variant of an immutable class, with the mutable class always being a subclass of the immutable one. If you need to dynamically change the encapsulated value or membership of such an object, you create an instance of the mutable class. Because it inherits from the immutable class, you can pass the mutable instance in methods that take the immutable type. For more on object mutability, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW33"&gt;“Object Mutability.”&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_739"&gt;&lt;/a&gt;Class clusters&lt;/strong&gt;. A class cluster is an abstract class and a set of private concrete subclasses for which the abstract class acts as an umbrella interface. Depending on the context (particularly the method you use to create an object), an instance of the appropriate optimized class is returned to you. &lt;code&gt;NSString&lt;/code&gt;and &lt;code&gt;NSMutableString&lt;/code&gt;, for example, act as brokers for instances of various private subclasses optimized for different kinds of storage needs. Over the years the set of concrete classes has changed several times without breaking applications. For more on class clusters, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW34"&gt;“Class Clusters.”&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_740"&gt;&lt;/a&gt;Notifications&lt;/strong&gt;. Notification is a major design pattern in Cocoa. It is based on a broadcast mechanism that allows objects (called &lt;em&gt;observers&lt;/em&gt;) to be kept informed of what another object is doing or is encountering in the way of user or system events. The object originating the notification can be unaware of the existence or identity of the observers of the notification. There are several types of notifications: synchronous, asynchronous, and distributed. The Foundation notification mechanism is implemented by the &lt;code&gt;NSNotification&lt;/code&gt;, &lt;code&gt;NSNotificationCenter&lt;/code&gt;, &lt;code&gt;NSNotificationQueue&lt;/code&gt;, and&lt;code&gt;NSDistributedNotificationCenter&lt;/code&gt; classes. For more on notifications, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-CH7-SW7"&gt;“Notifications.”&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW40"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Foundation Classes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The Foundation class hierarchy is rooted in the &lt;code&gt;NSObject&lt;/code&gt; class, which (along with the &lt;code&gt;NSObject&lt;/code&gt; and&lt;code&gt;NSCopying&lt;/code&gt; protocols) define basic object attributes and behavior. For further information on &lt;code&gt;NSObject&lt;/code&gt;and basic object behavior, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW35"&gt;“The Root Class.”&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The remainder of the Foundation framework consists of several related groups of classes as well as a few individual classes. There are classes representing basic data types such as strings and byte arrays, collection classes for storing other objects, classes representing system information such as dates, and classes representing system entities such as ports, threads, and processes. The &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_741"&gt;&lt;/a&gt;class hierarchy charts inFigure 1-7 (for printing purposes, in three parts) depict the logical groups these classes form as well as their inheritance relationships. Classes in blue-shaded areas are present in both the Mac OS X and iOS versions of Foundation; classes in gray-shaded areas are present only in the Mac OS X version.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW15"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-7&lt;/strong&gt;&amp;#160; The Foundation class hierarchy&lt;/p&gt;  &lt;p&gt;&lt;img alt="The Foundation class hierarchy" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/objc_foundation_A.jpg" width="373" height="498" /&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW13"&gt;&lt;/a&gt;&lt;img alt="Foundation class hierarchy—Objective-C (part two)" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/objc_foundation2_A.jpg" width="383" height="674" /&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW3"&gt;&lt;/a&gt;&lt;img alt="Foundation class hierarchy—Objective-C (part three)" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/objc_foundation3_A.jpg" width="374" height="642" /&gt;&lt;/p&gt;  &lt;p&gt;These diagrams logically group the classes of the Foundation framework in categories (with other associations pointed out). Of particular importance are the classes whose instances are value objects and collections.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW84"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Value Objects&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_742"&gt;&lt;/a&gt;Value objects encapsulate values of various primitive types, including strings, numbers (integers and floating-point values), dates, and even structures and pointers. They mediate access to these values and manipulate them in suitable ways. When you compare two value objects of the same class type, it is their encapsulated values that are compared, not their pointer values. Value objects are frequently the attributes of other objects, including custom objects.&lt;/p&gt;  &lt;p&gt;Of course, you may choose to use scalars and other primitive values directly in your program—after all, Objective-C is a superset of ANSI C—and in many cases using scalars is a reasonable thing to do. But in other situations, wrapping these values in objects is either advantageous or required. For example, because value objects are objects, you can, at runtime, find out their class type, determine the messages that can be sent to them, and perform other tasks that can be done with objects. The elements of collection objects such as arrays and dictionaries must be objects. And many if not most methods of the Cocoa frameworks that take and return values such as strings, numbers, and dates require that these values be encapsulated in objects. (With string values, in particular, you should always use &lt;code&gt;NSString&lt;/code&gt;objects and not C-strings.)&lt;/p&gt;  &lt;p&gt;Some classes for value objects have mutable and immutable variants—for example, there are the&lt;code&gt;NSMutableData&lt;/code&gt; and &lt;code&gt;NSData&lt;/code&gt; classes. The values encapsulated by immutable objects cannot be modified after they are created, whereas the values encapsulated by mutable objects can be modified. (&lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW33"&gt;“Object Mutability”&lt;/a&gt; discusses mutable and immutable objects in detail.)&lt;/p&gt;  &lt;p&gt;The following are descriptions of what the more important value objects do:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Instances of the &lt;code&gt;NSValue&lt;/code&gt; class encapsulate a single ANSI C or Objective-C data item—for example, scalar types such as floating-point values as well as pointers and structures&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;The &lt;code&gt;NSNumber&lt;/code&gt; class (a subclass of &lt;code&gt;NSValue&lt;/code&gt;) instantiates objects that contain numeric values such as integers, floats, and doubles.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Instances of the &lt;code&gt;NSData&lt;/code&gt; class provides object-oriented storage for streams of bytes (for example, image data). The class has methods for writing data objects to the file system and reading them back.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;The &lt;code&gt;NSDate&lt;/code&gt; class, along with the supporting &lt;code&gt;NSTimeZone&lt;/code&gt;, &lt;code&gt;NSCalendar&lt;/code&gt;, &lt;code&gt;NSDateComponents&lt;/code&gt;, and&lt;code&gt;NSLocale&lt;/code&gt; classes, provide objects that represent times, dates, calendar, and locales. They offer methods for calculating date and time differences, for displaying dates and times in many formats, and for adjusting times and dates based on location in the world.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Objects of the &lt;code&gt;NSString&lt;/code&gt; class (commonly referred to as &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_743"&gt;&lt;/a&gt;&lt;em&gt;strings&lt;/em&gt;) are a type of value object that provides object-oriented storage for a sequence of Unicode characters. Methods of &lt;code&gt;NSString&lt;/code&gt; can convert between representations of character strings, such as between UTF-8 and a null-terminated array of bytes in a particular encoding. &lt;code&gt;NSString&lt;/code&gt; also offers methods for searching, combining, and comparing strings and for manipulating file-system paths. Similar to &lt;code&gt;NSData&lt;/code&gt;, &lt;code&gt;NSString&lt;/code&gt; includes methods for writing strings to the file system and reading them back.&lt;/p&gt;      &lt;p&gt;The &lt;code&gt;NSString&lt;/code&gt; class also has a few associated classes. You can use an instance of the &lt;code&gt;NSScanner&lt;/code&gt;utility class to parse numbers and words from an &lt;code&gt;NSString&lt;/code&gt; object. &lt;code&gt;NSCharacterSet&lt;/code&gt; represents a set of characters that are used by various &lt;code&gt;NSString&lt;/code&gt; and &lt;code&gt;NSScanner&lt;/code&gt; methods. Attributed strings, which are instances of the &lt;code&gt;NSAttributedString&lt;/code&gt; class, manage ranges of characters that have attributes such as font and kerning associated with them.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Formatter objects—that is, objects derived from &lt;code&gt;NSFormatter&lt;/code&gt; and its descendent classes—are not themselves value objects, but they perform an important function related to value objects. They convert value objects such as &lt;code&gt;NSDate&lt;/code&gt; and &lt;code&gt;NSNumber&lt;/code&gt; instances to and from specific string representations, which are typically presented in the user interface.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW85"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Collections&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_744"&gt;&lt;/a&gt;Collections are objects that store other objects in a particular ordering scheme for later retrieval. Foundation defines three major collection classes that are common to both iOS and Mac OS X:&lt;code&gt;NSArray&lt;/code&gt;, &lt;code&gt;NSDictionary&lt;/code&gt;, and &lt;code&gt;NSSet&lt;/code&gt;. As with many of the value classes, these collection classes have immutable and mutable variants. For example, once you create an &lt;code&gt;NSArray&lt;/code&gt; object that holds a certain number of elements, you cannot add new elements or remove existing ones; for that purpose you need the &lt;code&gt;NSMutableArray&lt;/code&gt; class. (To learn about mutable and immutable objects, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW33"&gt;“Object Mutability.”&lt;/a&gt;)&lt;/p&gt;  &lt;p&gt;Objects of the major collection classes have some common behavioral characteristics and requirements. The items they contain must be objects, but the objects may be of any type. Collection objects, as with value objects, are essential components of property lists and, like all objects, can be archived and distributed. Moreover, collection objects automatically retain—that is, keep a strong reference to—any object they contain. If you remove an object from a mutable collection, it is released, which results in the object being freed if no other object claims it.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW86"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &amp;quot;Retain,” “release,” and related terms refer to memory-management of objects in Cocoa. To learn about this important topic, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW39"&gt;“Object Retention and Disposal.”&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The collection classes provide methods to access specific objects they contain. In addition, there are special enumerator objects (instances of &lt;code&gt;NSEnumerator&lt;/code&gt;) and language-level support to iterate through collections and access each element in sequence.&lt;/p&gt;  &lt;p&gt;The major collection classes are differentiated by the ordering schemes they use:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Arrays (&lt;code&gt;NSArray&lt;/code&gt;) are ordered collections that use zero-based indexing for accessing the elements of the collection.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Dictionaries (&lt;code&gt;NSDictionary&lt;/code&gt;) are collections managing pairs of keys and values; the key is an object that identifies the value, which is also an object. Because of this key-value scheme, the elements in a dictionary are unordered. Within a dictionary, the keys must be unique. Although they are typically string objects, keys can be any object that can be copied.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Sets (&lt;code&gt;NSSet&lt;/code&gt;) are similar to arrays, but they provide unordered storage of their elements instead of ordered storage. In other words, the order of elements in a set is not important. The items in an&lt;code&gt;NSSet&lt;/code&gt; object must be distinct from each other; however, an instance of the &lt;code&gt;NSCountedSet&lt;/code&gt; class (a subclass of &lt;code&gt;NSMutableSet&lt;/code&gt;) may include the same object more than once.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In Mac OS X, the Foundation framework includes several additional collection classes. &lt;code&gt;NSMapTable&lt;/code&gt; is a mutable dictionary-like collection class; however, unlike &lt;code&gt;NSDictionary&lt;/code&gt;, it can hold pointers as well as objects and it maintains weak references to its contained objects rather than strong references.&lt;code&gt;NSPointerArray&lt;/code&gt; is an array that can hold pointers and &lt;code&gt;NULL&lt;/code&gt; values and can maintain either strong or weak references to them. The &lt;code&gt;NSHashTable&lt;/code&gt; class is modeled after &lt;code&gt;NSSet&lt;/code&gt; but it can store pointers to functions and it provides different options, in particular to support weak relationships in a garbage-collected environment.&lt;/p&gt;  &lt;p&gt;For more on collection classes and objects, see &lt;em&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Collections/Collections.html#//apple_ref/doc/uid/10000034i"&gt;Collections Programming Topics&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW87"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Other Categories of Foundation Classes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The remaining classes of the Foundation framework fall into various categories, as indicated by the diagram in &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW15"&gt;Figure 1-7&lt;/a&gt;. The major categories of classes, shown in Figure 1-7, are described here:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_745"&gt;&lt;/a&gt;Operating-system services&lt;/strong&gt;. Many Foundation classes facilitate access of various lower-level services of the operating system and, at the same time, insulate you from operating-system idiosyncrasies. For example, &lt;code&gt;NSProcessInfo&lt;/code&gt; lets you query the environment in which an application runs and &lt;code&gt;NSHost&lt;/code&gt; yields the names and addresses of host systems on a network. You can use an&lt;code&gt;NSTimer&lt;/code&gt; object to send a message to another object at specific intervals, and &lt;code&gt;NSRunLoop&lt;/code&gt; lets you manage the input sources of an application or other type of program. &lt;code&gt;NSUserDefaults&lt;/code&gt; provides a programmatic interface to a system database of global (per-host) and per-user default values (preferences).&lt;/p&gt;      &lt;ul&gt;       &lt;li&gt;         &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_746"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_747"&gt;&lt;/a&gt;File system and URL&lt;/strong&gt;. &lt;code&gt;NSFileManager&lt;/code&gt; provides a consistent interface for file operations such as creating, renaming, deleting, and moving files. &lt;code&gt;NSFileHandle&lt;/code&gt; permits file operations at a lower level (for example, seeking within a file). &lt;code&gt;NSBundle&lt;/code&gt; finds resources stored in bundles and can dynamically load some of them (for example, nib files and code). You use &lt;code&gt;NSURL&lt;/code&gt; and related&lt;code&gt;NSURL...&lt;/code&gt; classes to represent, access, and manage URL sources of data.&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_748"&gt;&lt;/a&gt;Concurrency&lt;/strong&gt;. &lt;code&gt;NSThread&lt;/code&gt; lets you create multithreaded programs, and various lock classes offer mechanisms for controlling access to process resources by competing threads. You can use&lt;code&gt;NSOperation&lt;/code&gt; and &lt;code&gt;NSOperationQueue&lt;/code&gt; to perform multiple operations (concurrent or nonconcurrent) in priority and dependence order. With &lt;code&gt;NSTask&lt;/code&gt;, your program can fork off a child process to perform work and monitor its progress.&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_749"&gt;&lt;/a&gt;Interprocess communication&lt;/strong&gt;. Most of the classes in this category represent various kinds of system ports, sockets, and name servers and are useful in implementing low-level IPC. &lt;code&gt;NSPipe&lt;/code&gt;represents a BSD pipe, a unidirectional communications channel between processes.&lt;/p&gt;          &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW77"&gt;&lt;/a&gt;&lt;/p&gt;          &lt;p&gt;&lt;strong&gt;iOS Note:&lt;/strong&gt; The name server classes are not in the iOS version of Foundation.&lt;/p&gt;       &lt;/li&gt;        &lt;li&gt;         &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_750"&gt;&lt;/a&gt;Networking&lt;/strong&gt;. The &lt;code&gt;NSNetService&lt;/code&gt; and &lt;code&gt;NSNetServiceBrowser&lt;/code&gt; classes support the zero-configuration networking architecture called &lt;em&gt;Bonjour&lt;/em&gt;. Bonjour is a powerful system for publishing and browsing for services on an IP network.&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_751"&gt;&lt;/a&gt;&lt;/p&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Notifications&lt;/strong&gt;. See the summary of the notification classes in &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW7"&gt;“Foundation Paradigms and Policies.”&lt;/a&gt;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_752"&gt;&lt;/a&gt;Archiving and serialization&lt;/strong&gt;. The classes in this category make object distribution and persistence possible. &lt;code&gt;NSCoder&lt;/code&gt; and its subclasses, along with the &lt;code&gt;NSCoding&lt;/code&gt; protocol, represent the data an object contains in an architecture-independent way by allowing class information to be stored along with the data. &lt;code&gt;NSKeyedArchiver&lt;/code&gt; and &lt;code&gt;NSKeyedUnarchiver&lt;/code&gt; offer methods for encoding objects and scalar values and decoding them in a way that is not dependent on the ordering of encoding messages.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_753"&gt;&lt;/a&gt;Objective-C language services&lt;/strong&gt;. &lt;code&gt;NSException&lt;/code&gt; and &lt;code&gt;NSAssertionHandler&lt;/code&gt; provide an object-oriented way of making assertions and handling exceptions in code. An &lt;code&gt;NSInvocation&lt;/code&gt; object is a static representation of an Objective-C message that your program can store and later use to invoke a message in another object; it is used by the undo manager (&lt;code&gt;NSUndoManager&lt;/code&gt;) and by the distributed objects system. An &lt;code&gt;NSMethodSignature&lt;/code&gt; object records the type information of a method and is used in message forwarding. &lt;code&gt;NSClassDescription&lt;/code&gt; is an abstract class for defining and querying the relationships and properties of a class.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_754"&gt;&lt;/a&gt;XML processing&lt;/strong&gt;. Foundation on both platforms has the &lt;code&gt;NSXMLParser&lt;/code&gt; class, which is an object-oriented implementation of a streaming parser that enables you to process XML data in an event-driven way.&lt;/p&gt;      &lt;p&gt;Foundation in Mac OS X includes the NSXML classes (so called because the class names begin with “NSXML”). Objects of these classes represent an XML document as a hierarchical tree structure. This approach lets you to query this structure and manipulate its nodes. The NSXML classes support several XML-related technologies and standards, such as XQuery, XPath, XInclude, XSLT, DTD, and XHTML.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_755"&gt;&lt;/a&gt;Predicates and expressions&lt;/strong&gt;. The predicate classes—&lt;code&gt;NSPredicate&lt;/code&gt;, &lt;code&gt;NSCompoundPredicate&lt;/code&gt;, and &lt;code&gt;NSComparisonPredicate&lt;/code&gt;—encapsulate the logical conditions to constrain a fetch or filter object. &lt;code&gt;NSExpression&lt;/code&gt; objects represent expressions in a predicate.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The Foundation framework for iOS has a subset of the classes for Mac OS X. The following categories of classes are present only in the Mac OS X version of Foundation:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_756"&gt;&lt;/a&gt;Spotlight queries&lt;/strong&gt;. The &lt;code&gt;NSMetadataItem&lt;/code&gt;, &lt;code&gt;NSMetadataQuery&lt;/code&gt; and related query classes encapsulate file-system metadata and make it possible to query that metadata.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_757"&gt;&lt;/a&gt;Scripting&lt;/strong&gt;. The classes in this category help to make your program responsive to AppleScript scripts and Apple event commands.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_758"&gt;&lt;/a&gt;Distributed objects&lt;/strong&gt;. You use the distributed object classes for communication between processes on the same computer or on different computers on a network. Two of these classes,&lt;code&gt;NSDistantObject&lt;/code&gt; and &lt;code&gt;NSProtocolChecker&lt;/code&gt;, have a root class (&lt;code&gt;NSProxy&lt;/code&gt;) different from the root class of the rest of Cocoa.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW25"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;AppKit (Mac OS X)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_759"&gt;&lt;/a&gt;AppKit is a framework containing all the objects you need to implement your graphical, event-driven user interface in Mac OS X: windows, dialogs, buttons, menus, scrollers, text fields—the list goes on. AppKit handles all the details for you as it efficiently draws on the screen, communicates with hardware devices and screen buffers, clears areas of the screen before drawing, and clips views. The number of classes in AppKit may seem daunting at first. However, most AppKit classes are support classes that you use indirectly. You also have the choice at which level you use AppKit:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Use &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_760"&gt;&lt;/a&gt;Interface Builder to create connections from user-interface objects to your application’s controller objects, which manage the user interface and coordinate the flow of data between the user interface and internal data structures. For this, you might use off-the-shelf controller objects (for Cocoa bindings) or you may need to implement one or more custom controller classes—particularly the action and delegate methods of those classes. For example, you would need to implement a method that is invoked when the user chooses a menu item (unless it has a default implementation that is acceptable).&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Control the user interface programmatically, which requires more familiarity with AppKit classes and protocols. For example, allowing the user to drag an icon from one window to another requires some programming and familiarity with the &lt;code&gt;NSDragging...&lt;/code&gt; protocols.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Implement your own objects by &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_761"&gt;&lt;/a&gt;subclassing &lt;code&gt;NSView&lt;/code&gt; or other classes. When subclassing &lt;code&gt;NSView&lt;/code&gt;, you write your own drawing methods using graphics functions. Subclassing requires a deeper understanding of how AppKit works.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW41"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Overview of the AppKit Framework&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The AppKit framework consists of more than 125 classes and protocols. All classes ultimately inherit from the Foundation framework’s &lt;code&gt;NSObject&lt;/code&gt; class. The diagrams in Figure 1-8 show the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_762"&gt;&lt;/a&gt;inheritance relationships of the AppKit classes.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW1"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-8&lt;/strong&gt;&amp;#160; AppKit class hierarchy—Objective-C&lt;/p&gt;  &lt;p&gt;&lt;img alt="Application Kit class hierarchy—Objective-C" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/objc_appkit.jpg" width="627" height="598" /&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW9"&gt;&lt;/a&gt;&lt;img alt="Application Kit class hierarchy (part two)" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/objc_appkit2.jpg" width="425" height="693" /&gt;&lt;/p&gt;  &lt;p&gt;As you can see, the hierarchy tree of AppKit is broad but fairly shallow; the classes deepest in the hierarchy are a mere five superclasses away from the root class and most classes are much closer than that. Some of the major branches in this hierarchy tree are particularly interesting.&lt;/p&gt;  &lt;p&gt;At the root of the largest branch in AppKit is the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_763"&gt;&lt;/a&gt;&lt;code&gt;NSResponder&lt;/code&gt; class. This class defines the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_764"&gt;&lt;/a&gt;responder chain, an ordered list of objects that respond to user events. When the user clicks the mouse button or presses a key, an event is generated and passed up the responder chain in search of an object that can respond to it. Any object that handles events must inherit from the &lt;code&gt;NSResponder&lt;/code&gt; class. The core AppKit classes—&lt;code&gt;NSApplication&lt;/code&gt;, &lt;code&gt;NSWindow&lt;/code&gt;, and &lt;code&gt;NSView&lt;/code&gt;—inherit from &lt;code&gt;NSResponder&lt;/code&gt;.&lt;/p&gt;  &lt;p&gt;The second largest branch of classes in AppKit descend from &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_765"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_766"&gt;&lt;/a&gt;&lt;code&gt;NSCell&lt;/code&gt;. The noteworthy thing about this group of classes is that they roughly mirror the classes that inherit from &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_767"&gt;&lt;/a&gt;&lt;code&gt;NSControl&lt;/code&gt;, which inherits from&lt;code&gt;NSView&lt;/code&gt;. For its user-interface objects that respond to user actions, AppKit uses an architecture that divides the labor between control objects and cell objects. The &lt;code&gt;NSControl&lt;/code&gt; and &lt;code&gt;NSCell&lt;/code&gt; classes, and their subclasses, define a common set of user-interface objects such as buttons, sliders, and browsers that the user can manipulate graphically to control some aspect of your application. Most control objects are associated with one or more cell objects that implement the details of drawing and handling events. For example, a button comprises both an &lt;code&gt;NSButton&lt;/code&gt; object and an &lt;code&gt;NSButtonCell&lt;/code&gt; object.&lt;/p&gt;  &lt;p&gt;Controls and cells implement a mechanism that is based on an important design pattern of the AppKit: the&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_768"&gt;&lt;/a&gt;target-action mechanism. A cell can hold information that identifies the message that should be sent to a particular object when the user clicks (or otherwise acts upon) the cell. When a user manipulates a control (by, for example, clicking it), the control extracts the required information from its cell and sends an action message to the target object. Target-action allows you to give meaning to a user action by specifying what the target object and invoked method should be. You typically use &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_769"&gt;&lt;/a&gt;Interface Builder to set these targets and actions by Control-dragging from the control object to your application or other object. You can also set targets and actions programmatically.&lt;/p&gt;  &lt;p&gt;Another important design pattern–based mechanism of AppKit (and also UIKit) is &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_770"&gt;&lt;/a&gt;delegation. Many objects in a user interface, such as text fields and table views, define a delegate. A delegate is an object that acts on behalf of, or in coordination with, the delegating object. It is thus able to impart application-specific logic to the operation of the user interface. For more on delegation, target–action, and other paradigms and mechanisms of AppKit, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-CH7-SW15"&gt;“Communicating with Objects.”&lt;/a&gt; For a discussion of the design patterns on which these paradigms and mechanisms are based, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW6"&gt;“Cocoa Design Patterns.”&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;One of the general features of Mac OS X v10.5 and later system versions is resolution independence: The resolution of the screen is decoupled from the drawing done by code. The system automatically scales content for rendering on the screen. The AppKit classes support resolution independence in their user-interface objects. However, for your own applications to take advantage of resolution independence, you might have to supply images at a higher resolution or make minor adjustments in your drawing code that take the current scaling factor into account.&lt;/p&gt;  &lt;p&gt;The following sections briefly describe some of the capabilities and architectural aspects of the AppKit framework and its classes and protocols. It groups classes according to the class hierarchy diagrams shown in &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW1"&gt;Figure 1-8&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW42"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;General User-Interface Classes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;For the overall functioning of a user interface, the AppKit provides the following classes:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;The &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_771"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_772"&gt;&lt;/a&gt;global application object&lt;/strong&gt;. Every application uses a singleton instance of &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_773"&gt;&lt;/a&gt;&lt;code&gt;NSApplication&lt;/code&gt; to control the main event loop, keep track of the application’s windows and menus, distribute events to the appropriate objects (that is, itself or one of its windows), set up top-level autorelease pools, and receive notification of application-level events. An &lt;code&gt;NSApplication&lt;/code&gt; object has a delegate (an object that you assign) that is notified when the application starts or terminates, is hidden or activated, should open a file selected by the user, and so forth. By setting the &lt;code&gt;NSApplication&lt;/code&gt; object’s delegate and implementing the delegate methods, you customize the behavior of your application without having to subclass &lt;code&gt;NSApplication&lt;/code&gt;.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Windows and views&lt;/strong&gt;. The window and view classes, &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_774"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_775"&gt;&lt;/a&gt;&lt;code&gt;NSWindow&lt;/code&gt; and &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_776"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_777"&gt;&lt;/a&gt;&lt;code&gt;NSView&lt;/code&gt;, also inherit from&lt;code&gt;NSResponder&lt;/code&gt;, and so are designed to respond to user actions. An &lt;code&gt;NSApplication&lt;/code&gt; object maintains a list of &lt;code&gt;NSWindow&lt;/code&gt; objects—one for each window belonging to the application—and each&lt;code&gt;NSWindow&lt;/code&gt; object maintains a hierarchy of &lt;code&gt;NSView&lt;/code&gt; objects. The view hierarchy is used for drawing and handling events within a window. An &lt;code&gt;NSWindow&lt;/code&gt; object handles window-level events, distributes other events to its views, and provides a drawing area for its views. An &lt;code&gt;NSWindow&lt;/code&gt; object also has a delegate allowing you to customize its behavior.&lt;/p&gt;      &lt;p&gt;Beginning with Mac OS X v10.5, the window and view classes of the AppKit support enhanced animation features.&lt;/p&gt;      &lt;p&gt;&lt;code&gt;NSView&lt;/code&gt; is the superclass for all objects displayed in a window. All subclasses implement a drawing method using graphics functions; &lt;code&gt;drawRect:&lt;/code&gt; is the primary method you override when creating a new&lt;code&gt;NSView&lt;/code&gt;.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Controller classes for Cocoa bindings&lt;/strong&gt;. The abstract &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_778"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_779"&gt;&lt;/a&gt;&lt;code&gt;NSController&lt;/code&gt; class and its concrete subclasses &lt;code&gt;NSObjectController&lt;/code&gt;, &lt;code&gt;NSArrayController&lt;/code&gt;, &lt;code&gt;NSDictionaryController&lt;/code&gt;, and&lt;code&gt;NSTreeController&lt;/code&gt; are part of the implementation of Cocoa bindings. This technology automatically synchronizes the application data stored in objects and the presentation of that data in a user interface. See &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html#//apple_ref/doc/uid/TP40002974-CH6-SW1"&gt;“The Model-View-Controller Design Pattern”&lt;/a&gt; for a description of these types of controller objects.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_780"&gt;&lt;/a&gt;Panels (dialogs)&lt;/strong&gt;. The &lt;code&gt;NSPanel&lt;/code&gt; class is a subclass of &lt;code&gt;NSWindow&lt;/code&gt; that you use to display transient, global, or pressing information. For example, you would use an instance of &lt;code&gt;NSPanel&lt;/code&gt;, rather than an instance of &lt;code&gt;NSWindow&lt;/code&gt;, to display error messages or to query the user for a response to remarkable or unusual circumstances. The AppKit implements some common dialogs for you such as the Save, Open, and Print dialogs, used to save, open, and print documents. Using these dialogs gives the user a consistent look and feel across applications for common operations.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_781"&gt;&lt;/a&gt;Menus and cursors&lt;/strong&gt;. The &lt;code&gt;NSMenu&lt;/code&gt;, &lt;code&gt;NSMenuItem&lt;/code&gt;, and &lt;code&gt;NSCursor&lt;/code&gt; classes define the look and behavior of the menus and cursors that your application displays to the user.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Grouping and scrolling views&lt;/strong&gt;. The &lt;code&gt;NSBox&lt;/code&gt;, &lt;code&gt;NSScrollView&lt;/code&gt;, and &lt;code&gt;NSSplitView&lt;/code&gt; classes provide graphic “accessories” to other view objects or collections of views in windows. With the &lt;code&gt;NSBox&lt;/code&gt; class, you can group elements in windows and draw a border around the entire group. The &lt;code&gt;NSSplitView&lt;/code&gt;class lets you append views vertically or horizontally, apportioning to each view some amount of a common territory; a sliding control bar lets the user redistribute the territory among views. The&lt;code&gt;NSScrollView&lt;/code&gt; class and its helper class, &lt;code&gt;NSClipView&lt;/code&gt;, provide a scrolling mechanism as well as the graphic objects that let the user initiate and control a scroll. The &lt;code&gt;NSRulerView&lt;/code&gt; class allows you to add a ruler and markers to a scroll view.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_782"&gt;&lt;/a&gt;Table views and &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_783"&gt;&lt;/a&gt;outline views&lt;/strong&gt;. The &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_784"&gt;&lt;/a&gt;&lt;code&gt;NSTableView&lt;/code&gt; class displays data in rows and columns.&lt;code&gt;NSTableView&lt;/code&gt; is ideal for, but not limited to, displaying database records, where rows correspond to each record and columns contain record attributes. The user can edit individual cells and rearrange the columns. You control the behavior and content of an &lt;code&gt;NSTableView&lt;/code&gt; object by setting its delegate and data source objects. Outline views (instances of &lt;code&gt;NSOutlineView&lt;/code&gt;, a subclass of &lt;code&gt;NSTableView&lt;/code&gt;) offer another approach to displaying tabular data. With the &lt;code&gt;NSBrowser&lt;/code&gt; class you can create an object with which users can display and navigate hierarchical data.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW43"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Text and Fonts&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The Cocoa text system is based on the Core Text framework, which was introduced in Mac OS X v10.5. The Core Text framework provides a modern, low-level, high-performance technology for laying out text. If you use the Cocoa text system, you should rarely have reason to use Core Text directly.&lt;/p&gt;  &lt;p&gt;The &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_785"&gt;&lt;/a&gt;&lt;code&gt;NSTextField&lt;/code&gt; class implements a simple editable text-input field, and the &lt;code&gt;NSTextView&lt;/code&gt; class provides more comprehensive editing features for larger text bodies.&lt;/p&gt;  &lt;p&gt;&lt;code&gt;NSTextView&lt;/code&gt;, a subclass of the abstract &lt;code&gt;NSText&lt;/code&gt; class, defines the interface to the extended text system. &lt;code&gt;NSTextView&lt;/code&gt; supports rich text, attachments (graphics, file, and other), input management and key binding, and marked text attributes. &lt;code&gt;NSTextView&lt;/code&gt; works with the Fonts window and Font menu, rulers and paragraph styles, the Services facility, and the pasteboard (Clipboard). &lt;code&gt;NSTextView&lt;/code&gt; also allows customizing through delegation and notifications—you rarely need to subclass &lt;code&gt;NSTextView&lt;/code&gt;. You rarely create instances of &lt;code&gt;NSTextView&lt;/code&gt; programmatically either, because objects in the Interface Builder library, such as &lt;code&gt;NSTextField&lt;/code&gt;, &lt;code&gt;NSForm&lt;/code&gt;, and &lt;code&gt;NSScrollView&lt;/code&gt;, already contain &lt;code&gt;NSTextView&lt;/code&gt; objects.&lt;/p&gt;  &lt;p&gt;It is also possible to do more powerful and more creative text manipulation (such as displaying text in a circle) using &lt;code&gt;NSTextStorage&lt;/code&gt;, &lt;code&gt;NSLayoutManager&lt;/code&gt;, &lt;code&gt;NSTextContainer&lt;/code&gt;, and related classes. The Cocoa text system also supports lists, tables, and noncontiguous selections.&lt;/p&gt;  &lt;p&gt;The &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_786"&gt;&lt;/a&gt;&lt;code&gt;NSFont&lt;/code&gt; and &lt;code&gt;NSFontManager&lt;/code&gt; classes encapsulate and manage font families, sizes, and variations. The &lt;code&gt;NSFont&lt;/code&gt; class defines a single object for each distinct font; for efficiency, these objects, which can represent a lot of data, are shared by all the objects in your application. The &lt;code&gt;NSFontPanel&lt;/code&gt; class defines the Fonts window that’s presented to the user.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW44"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Graphics and Colors&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The classes &lt;code&gt;NSImage&lt;/code&gt; and &lt;code&gt;NSImageRep&lt;/code&gt; encapsulate graphics data, allowing you to easily and efficiently access &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_787"&gt;&lt;/a&gt;images stored in files on the disk and displayed on the screen. &lt;code&gt;NSImageRep&lt;/code&gt; subclasses each know how to draw an image from a particular kind of source data. The &lt;code&gt;NSImage&lt;/code&gt; class provides multiple representations of the same image, and it also provides behaviors such as caching. The imaging and drawing capabilities of Cocoa are integrated with the Core Image framework.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_788"&gt;&lt;/a&gt;Color is supported by the classes &lt;code&gt;NSColor&lt;/code&gt;, &lt;code&gt;NSColorSpace&lt;/code&gt;, &lt;code&gt;NSColorPanel&lt;/code&gt;, &lt;code&gt;NSColorList&lt;/code&gt;,&lt;code&gt;NSColorPicker&lt;/code&gt;, and &lt;code&gt;NSColorWell&lt;/code&gt;. &lt;code&gt;NSColor&lt;/code&gt; and &lt;code&gt;NSColorSpace&lt;/code&gt; support a rich set of color formats and representations, including custom ones. The other classes are mostly interface classes: They define and present panels and views that allow the user to select and apply colors. For example, the user can drag colors from the Colors window to any color well.&lt;/p&gt;  &lt;p&gt;The &lt;code&gt;NSGraphicsContext&lt;/code&gt;, &lt;code&gt;NSBezierPath&lt;/code&gt;, and &lt;code&gt;NSAffineTransform&lt;/code&gt; classes help you with &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_789"&gt;&lt;/a&gt;vector drawing and support &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_790"&gt;&lt;/a&gt;graphical transformations such as scaling, rotation, and translation.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW45"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Printing and Faxing&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The &lt;code&gt;NSPrinter&lt;/code&gt;, &lt;code&gt;NSPrintPanel&lt;/code&gt;, &lt;code&gt;NSPageLayout&lt;/code&gt;, and &lt;code&gt;NSPrintInfo&lt;/code&gt; classes work together to provide the means for &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_791"&gt;&lt;/a&gt;printing and &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_792"&gt;&lt;/a&gt;faxing the information that your application displays in its windows and views. You can also create a PDF representation of an &lt;code&gt;NSView&lt;/code&gt; object.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW46"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Document and File-System Support&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_793"&gt;&lt;/a&gt;You can use the &lt;code&gt;NSFileWrapper&lt;/code&gt; class to create objects that correspond to files or directories on disk.&lt;code&gt;NSFileWrapper&lt;/code&gt; holds the contents of the file in memory so that it can be displayed, changed, or transmitted to another application. It also provides an icon for dragging the file or representing it as an attachment. You can use the &lt;code&gt;NSFileManager&lt;/code&gt; class in the Foundation framework to access and enumerate file and directory contents. The &lt;code&gt;NSOpenPanel&lt;/code&gt; and &lt;code&gt;NSSavePanel&lt;/code&gt; classes also provide a convenient and familiar user interface to the file system.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_794"&gt;&lt;/a&gt;The &lt;code&gt;NSDocumentController&lt;/code&gt;, &lt;code&gt;NSDocument&lt;/code&gt;, and &lt;code&gt;NSWindowController&lt;/code&gt; classes define an architecture for creating &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_795"&gt;&lt;/a&gt;document-based applications. (The &lt;code&gt;NSWindowController&lt;/code&gt; class is shown in the User Interface group of classes in the class hierarchy charts.) Such applications can generate identical window containers that hold uniquely composed sets of data that can be stored in files. They have built-in or easily acquired capabilities for saving, opening, reverting, closing, and managing these documents.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW47"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Internationalization and Character Input Support&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_796"&gt;&lt;/a&gt;If an application is to be used in more than one part of the world, its resources may need to be customized, or localized, for language, country, or cultural region. For example, an application may need to have separate Japanese, English, French, and German versions of character strings, icons, nib files, or context help. Resource files specific to a particular language are grouped together in a subdirectory of the bundle directory (the directories with the &lt;code&gt;.lproj&lt;/code&gt; extension). Usually you set up localization resource files using Interface Builder. See &lt;em&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/BPInternational.html#//apple_ref/doc/uid/10000171i"&gt;Internationalization Programming Topics&lt;/a&gt;&lt;/em&gt; for more information on the Cocoa internationalization facilities.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_797"&gt;&lt;/a&gt;The &lt;code&gt;NSInputServer&lt;/code&gt; and &lt;code&gt;NSInputManager&lt;/code&gt; classes, along with the &lt;code&gt;NSTextInput&lt;/code&gt; protocol, give your application access to the text input management system. This system interprets keystrokes generated by various international keyboards and delivers the appropriate text characters or Control-key events to text view objects. (Typically the text classes deal with these classes and you won’t have to.)&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW48"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Operating-System Services&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The AppKit provides operating-system support for your application through classes that implement the following features:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Sharing data with other applications&lt;/strong&gt;. The &lt;code&gt;NSPasteboard&lt;/code&gt; class defines the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_798"&gt;&lt;/a&gt;pasteboard, a repository for data that’s copied from your application, making this data available to any application that cares to use it. &lt;code&gt;NSPasteboard&lt;/code&gt; implements the familiar &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_799"&gt;&lt;/a&gt;cut/copy-and-paste operation.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_800"&gt;&lt;/a&gt;Dragging&lt;/strong&gt;. With very little programming on your part, custom view objects can be dragged and dropped anywhere. Objects become part of this dragging mechanism by conforming to&lt;code&gt;NSDragging...&lt;/code&gt; protocols; draggable objects conform to the &lt;code&gt;NSDraggingSource&lt;/code&gt; protocol, and destination objects (receivers of a drop) conform to the &lt;code&gt;NSDraggingDestination&lt;/code&gt; protocol. The AppKit hides all the details of tracking the cursor and displaying the dragged image.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_801"&gt;&lt;/a&gt;Spell Checking&lt;/strong&gt;. The &lt;code&gt;NSSpellServer&lt;/code&gt; class lets you define a spell-checking service and provide it as a service to other applications. To connect your application to a spell-checking service, you use the&lt;code&gt;NSSpellChecker&lt;/code&gt; class. The &lt;code&gt;NSIgnoreMisspelledWords&lt;/code&gt; and &lt;code&gt;NSChangeSpelling&lt;/code&gt; protocols support the spell-checking mechanism.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW49"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Interface Builder Support&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The abstract &lt;code&gt;NSNibConnector&lt;/code&gt; class and its two concrete subclasses, &lt;code&gt;NSNibControlConnector&lt;/code&gt; and&lt;code&gt;NSNibOutletConnector&lt;/code&gt;, represent connections in Interface Builder. &lt;code&gt;NSNibControlConnector&lt;/code&gt;manages an action connection in Interface Builder and &lt;code&gt;NSNibOutletConnector&lt;/code&gt; manages an outlet connection.&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_802"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW22"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;UIKit (iOS)&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The UIKit framework in iOS is the sister framework of the AppKit framework in Mac OS X. Its purpose is essentially the same: to provide all the classes that an application needs to construct and manage its user interface. However, there are significant differences in how the frameworks realize this purpose.&lt;/p&gt;  &lt;p&gt;One of the greatest differences is that, in iOS, the objects that appear in the user interface of a Cocoa application look and behave in a way that is different from the way their counterparts in a Cocoa application running in Mac OS X look and behave. Some common examples are text views, table views, and buttons. In addition, the event-handling and drawing models for Cocoa applications on the two platforms are significantly different. The following sections explain the reasons for these and other differences.&lt;/p&gt;  &lt;p&gt;You can add UIKit objects to your application’s user interface in three ways:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Use the Interface Builder development application to drag windows, views, and other objects from an object library.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Create, position, and configure framework objects programmatically.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Implement custom user-interface objects by subclassing &lt;code&gt;UIView&lt;/code&gt; or classes that inherit from &lt;code&gt;UIView&lt;/code&gt;.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW50"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Overview of UIKit Classes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As with AppKit, the classes of the UIKit framework ultimately inherit from &lt;code&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html#//apple_ref/occ/cl/NSObject"&gt;NSObject&lt;/a&gt;&lt;/code&gt;. Figure 1-9 presents the classes of the UIKit framework in their inheritance relationship.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW26"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-9&lt;/strong&gt;&amp;#160; UIKit class hierarchy&lt;img alt="UIKit class hierarchy" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/uikit_classes.jpg" width="873" height="1159" /&gt;&lt;/p&gt;  &lt;p&gt;As with AppKit, a base responder class is at the root of the largest branch of UIKit classes.&lt;code&gt;UIResponder&lt;/code&gt; also defines the interface and default behavior (if any) for event-handling methods and for the responder chain, which is a chain of objects that are potential event handlers. When the user scrolls a table view with his or her finger or types characters in a virtual keyboard, UIKit generates an event and that event is passed up the responder chain until an object handles it. The corresponding core objects—application (&lt;code&gt;UIApplication&lt;/code&gt;), window (&lt;code&gt;UIWindow&lt;/code&gt;), and view (&lt;code&gt;UIView&lt;/code&gt;)—all directly or indirectly inherit from &lt;code&gt;UIResponder&lt;/code&gt;.&lt;/p&gt;  &lt;p&gt;Unlike the AppKit, UIKit does not make use of cells. Controls in UIKit—that is, all objects that inherit from&lt;code&gt;UIControl&lt;/code&gt;—do not require cells to carry out their primary role: sending action messages to a target object. Yet the way UIKit implements the target-action mechanism is different from the way it is implemented in AppKit. The &lt;code&gt;UIControl&lt;/code&gt; class defines a set of event types for controls; if, for example, you want a button (&lt;code&gt;UIButton&lt;/code&gt;) to send an action message to a target object, you call &lt;code&gt;UIControl&lt;/code&gt;methods to associate the action and target with one or more of the control event types. When one of those events happens, the control sends the action message.&lt;/p&gt;  &lt;p&gt;The UIKit framework makes considerable use of delegation, another design pattern of AppKit. Yet the UIKit implementation of delegation is different. Instead of using informal protocols, UIKit uses formal protocols with possibly some protocol methods marked optional.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW80"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; For a complete description of the target-action mechanism in UIKit and the AppKit, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-CH7-SW14"&gt;“The Target-Action Mechanism.”&lt;/a&gt; To learn more about delegation and protocols, both formal and informal, see &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-CH7-SW18"&gt;“Delegates and Data Sources”&lt;/a&gt; and &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW41"&gt;“Protocols.”&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW51"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Application Coordination&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Each application running in iOS is managed by a singleton application object, and this object has a job that is almost identical to that for the global &lt;code&gt;NSApplication&lt;/code&gt; object. A &lt;code&gt;UIApplication&lt;/code&gt; object controls the main event loop, keeps track of the application’s windows and views, and dispatches incoming events to the appropriate responder objects.&lt;/p&gt;  &lt;p&gt;The &lt;code&gt;UIApplication&lt;/code&gt; object also receives notification of system-level and application-level events. Many of these it passes to its delegate, allowing it to inject application-specific behavior when the application launches and terminates, to respond to low-memory warnings and changes in time, and to handle other tasks.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW52"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Differences in Event and Drawing Models&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;In Mac OS X, the mouse and keyboard generate most user events. AppKit uses &lt;code&gt;NSEvent&lt;/code&gt; objects to encapsulate these events. In iOS, however, a user’s finger movements on the screen are what originate events. UIKit also has a class, &lt;code&gt;UIEvent&lt;/code&gt;, to represent these events. But finger touches are different in nature from mouse clicks; two or more touches occurring over a period could form a discrete event—a pinch gesture, for example. Thus a &lt;code&gt;UIEvent&lt;/code&gt; object contains one or more objects representing finger touches (&lt;code&gt;UITouch&lt;/code&gt;). The model for distributing and dispatching events to objects that can handle them on the two platforms is almost identical. However, to handle an event, an object must take into consideration the sequence of touches specific to that event.&lt;/p&gt;  &lt;p&gt;UIKit also has gesture recognizers, objects that automate the detection of touches as gestures. A gesture recognizer analyzes a series of touches and, when it recognizes its gesture, sends an action message to a target. UIKit provides ready-made gesture recognizers for gestures such as tap, swipe, rotate, and pan. You can also create custom gesture recognizers that detect application-specific gestures.&lt;/p&gt;  &lt;p&gt;The drawing models are similar for AppKit and UIKit. Animation is integrated into the UIKit drawing implementation. The programmatic support that UIKit directly provides for drawing is a bit more limited compared to AppKit. The framework offers classes and functions for Bezier paths, PDF generation, and simple line and rectangle drawing (through functions declared in &lt;code&gt;UIGraphics.h&lt;/code&gt;). You use &lt;code&gt;UIColor&lt;/code&gt;objects to set colors in the current graphics context and &lt;code&gt;UIImage&lt;/code&gt; objects to represent and encapsulate images. For drawing of greater sophistication, an application must use the Core Graphics or OpenGL ES framework.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW24"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;General User-Interface Classes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Objects on an iOS user interface are visibly different than objects on a Mac OS X user interface. Because of the nature of the device—specifically the smaller screen size and the use of fingers instead of the mouse and keyboard for input—user-interface objects in iOS must typically be larger (to be an adequate target for touches) while at the same time make as efficient use of screen real estate as possible. These objects are sometimes based on visual and tactile analogs of an entirely different sort. As an example, consider the date picker object, which is instantiated from a class that both the UIKit and AppKit frameworks define. In Mac OS X, the date picker looks like this:&lt;/p&gt;  &lt;p&gt;&lt;img alt="A date picker in Cocoa on Mac OS X" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/datepicker_osx.jpg" width="111" height="32" /&gt;&lt;/p&gt;  &lt;p&gt;This style of date picker has a two tiny areas for incrementing date components, and thus is suited to manipulation by a mouse pointer. Contrast this with the date picker seen in iOS applications:&lt;/p&gt;  &lt;p&gt;&lt;img alt="A date picker in Aspen" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/datepicker_a.jpg" width="277" height="183" /&gt;&lt;/p&gt;  &lt;p&gt;This style of date picker is more suited for finger touches as an input source; users can swipe a month, day, or year column to spin it to a new value.&lt;/p&gt;  &lt;p&gt;As with AppKit classes, many of UIKit classes fall into functional groups:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Controls&lt;/strong&gt;. The subclasses of &lt;code&gt;UIControl&lt;/code&gt; instantiate objects that let users communicate their intent to an application. In addition to the standard button object (&lt;code&gt;UIButton&lt;/code&gt;) and slider object (&lt;code&gt;UISlider&lt;/code&gt;), there is a control that simulates off/on switches (&lt;code&gt;UISwitch&lt;/code&gt;), a spinning-wheel control for selecting from multidimensional sets of values (&lt;code&gt;UIPickerView&lt;/code&gt;), a control for paging through documents (&lt;code&gt;UIPageControl&lt;/code&gt;), and other controls.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Modal views&lt;/strong&gt;. The two classes inheriting from &lt;code&gt;UIModalView&lt;/code&gt; are for displaying messages to users either in the form of “sheets” attached to specific views or windows (&lt;code&gt;UIActionSheet&lt;/code&gt;) or as unattached alert dialogs (&lt;code&gt;UIAlertView&lt;/code&gt;). On iPad, an application can uses popover views (&lt;code&gt;UIPopoverController&lt;/code&gt;) instead of action sheets.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Scroll views&lt;/strong&gt;. The &lt;code&gt;UIScrollView&lt;/code&gt; class enables instances of its subclasses to respond to touches for scrolling within large views. As users scroll, the scroll view displays transient indicators of position within the document. The subclasses of &lt;code&gt;UIScrollView&lt;/code&gt; implement table views, text views, and web views.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;strong&gt;Toolbars, navigation bars, split views, and view controllers&lt;/strong&gt;. The &lt;code&gt;UIViewController&lt;/code&gt; class is a base class for managing a view. A view controller provides methods for creating and observing views, overlaying views, handling view rotation, and responding to low-memory warnings. UIKit includes concrete subclasses of &lt;code&gt;UIViewController&lt;/code&gt; for managing toolbars, navigation bars, and image pickers.&lt;/p&gt;      &lt;p&gt;Applications use both toolbars and navigation bars to manage behavior related to the “main” view on the screen; typically, toolbars are placed beneath the main view and navigation bars above it. You use toolbar (&lt;code&gt;UIToolbar&lt;/code&gt;) objects to switch between modes or views of an application; you can also use them to display a set of functions that perform some action related to the current main view. You use navigation bars (&lt;code&gt;UINavigationBar&lt;/code&gt;) to manage sequences of windows or views in an application and, in effect, to “drill down” a hierarchy of objects defined by the application; the Mail application, for example, uses a navigation bar to navigate from accounts to mailbox folders and from there to individual email messages. On iPad, applications can use a &lt;code&gt;UISplitViewController&lt;/code&gt; object to present a master-detail interface.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW53"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Text&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Users can enter text in an iOS application either through a text view (&lt;code&gt;UITextView&lt;/code&gt;) or a text field (&lt;code&gt;UITextField&lt;/code&gt;). These classes adopt the &lt;code&gt;UITextInputTraits&lt;/code&gt; protocol to specify the appearance and behavior of the virtual keyboard that is presented when users touch the text-entry object; any subclasses that enable entry of text should also conform to this protocol. Applications can draw text in views using &lt;code&gt;UIStringDrawing&lt;/code&gt; methods, a category on the &lt;code&gt;NSString&lt;/code&gt; class. And with the &lt;code&gt;UIFont&lt;/code&gt;class you can specify the font characteristics of text in all objects that display text, including table cells, navigation bars, and labels.&lt;/p&gt;  &lt;p&gt;Applications that do their own text layout and font management can adopt the &lt;code&gt;UITextInput&lt;/code&gt; protocol and use related classes and protocols to communicate with the text input system of iOS.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW55"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Comparing AppKit and UIKit Classes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;AppKit and UIKit are Cocoa application frameworks that are designed for different platforms, one for Mac OS X and the other for iOS. Because of this affinity, it is not surprising that many of the classes in each framework have similar names; in most cases, the prefix (“NS” versus “UI”) is the only name difference. These similarly named classes fulfill mostly similar roles, but there are differences. These differences can be a matter of scope, of inheritance, or of design. Generally, UIKit classes have fewer methods than their AppKit counterparts.&lt;/p&gt;  &lt;p&gt;Table 1-1 describes the differences between the major classes in each framework.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW56"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Table 1-1&lt;/strong&gt;&amp;#160; Major classes of the AppKit and UIKit frameworks&lt;/p&gt;  &lt;p&gt;Classes&lt;/p&gt;  &lt;p&gt;Comparison&lt;/p&gt;  &lt;p&gt;&lt;code&gt;NSApplication&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;UIApplication&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;The classes are strikingly similar in their primary roles. They provide a singleton object that sets up the application’s display environment and event loop, distributes events, and notifies a delegate when application-specific events occur (such as launch and termination). However, the&lt;code&gt;NSApplication&lt;/code&gt; class performs functions (for example, managing application suspension, reactivation, and hiding) that are not available to an iOS application.&lt;/p&gt;  &lt;p&gt;&lt;code&gt;NSResponder&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;UIResponder&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;These classes also have nearly identical roles. They are abstract classes that define an interface for responding to events and managing the responder chain. The main difference is that the &lt;code&gt;NSResponder&lt;/code&gt; event-handling methods are defined for the mouse and keyboard, whereas the &lt;code&gt;UIResponder&lt;/code&gt;methods are defined for the Multi-Touch event model.&lt;/p&gt;  &lt;p&gt;&lt;code&gt;NSWindow&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;UIWindow&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;The &lt;code&gt;UIWindow&lt;/code&gt; class occupies a place in the class hierarchy different from the place &lt;code&gt;NSWindow&lt;/code&gt; occupies in AppKit; it is a subclass of &lt;code&gt;UIView&lt;/code&gt;, whereas the AppKit class inherits directly from &lt;code&gt;NSResponder&lt;/code&gt;. &lt;code&gt;UIWindow&lt;/code&gt; has a much more restricted role in an application than does &lt;code&gt;NSWindow&lt;/code&gt;. It also provides an area for displaying views, dispatches events to those views, and converts between window and view coordinates.&lt;/p&gt;  &lt;p&gt;&lt;code&gt;NSView&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;UIView&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;These classes are very similar in purpose and in their basic sets of methods. They allow you to move and resize views, manage the view hierarchy, draw view content, and convert view coordinates. The design of &lt;code&gt;UIView&lt;/code&gt;, however, makes view objects inherently capable of animation.&lt;/p&gt;  &lt;p&gt;&lt;code&gt;NSControl&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;UIControl&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;Both classes define a mechanism for objects such as buttons and sliders so that, when manipulated, the control object sends an action message to a target object. The classes implement the target-action mechanism in different ways, largely because of the difference between event models. See &lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-CH7-SW14"&gt;“The Target-Action Mechanism”&lt;/a&gt; for information.&lt;/p&gt;  &lt;p&gt;&lt;code&gt;NSViewController&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;UIViewController&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;The role of both of these classes is, as their names suggest, to manage views. How they accomplish this task is different. The management provided by an &lt;code&gt;NSViewController&lt;/code&gt; object is dependent on bindings, which is a technology supported only in Mac OS X. &lt;code&gt;UIViewController&lt;/code&gt; objects are used in the iOS application model for modal and navigation user interfaces (for example, the views controlled by navigation bars).&lt;/p&gt;  &lt;p&gt;&lt;code&gt;NSTableView&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;UITableView&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;NSTableView&lt;/code&gt; inherits from &lt;code&gt;NSControl&lt;/code&gt;, but &lt;code&gt;UITableView&lt;/code&gt; does not inherit from &lt;code&gt;UIControl&lt;/code&gt;. More importantly, &lt;code&gt;NSTableView&lt;/code&gt; objects support multiple columns of data; &lt;code&gt;UITableView&lt;/code&gt; objects display only a single column of data at a time, and thus function more as lists than presentations of tabular data.&lt;/p&gt;  &lt;p&gt;Among the minor classes you can find some differences too. For example, UIKit has the &lt;code&gt;UITextField&lt;/code&gt;and &lt;code&gt;UILabel&lt;/code&gt; classes, the former for editable text fields and the latter for noneditable text fields used as labels; with the &lt;code&gt;NSTextField&lt;/code&gt; class you can create both kinds of text fields simply by setting text-field attributes. Similarly, the &lt;code&gt;NSProgressIndicator&lt;/code&gt; class can create objects in styles that correspond to instances of the &lt;code&gt;UIProgressIndicator&lt;/code&gt; and &lt;code&gt;UIProgressBar&lt;/code&gt; classes.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW88"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Core Data&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_803"&gt;&lt;/a&gt;Core Data is a Cocoa framework that provides an infrastructure for managing &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_804"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_805"&gt;&lt;/a&gt;object graphs, including support for persistent storage in a variety of file formats. Object-graph management includes features such as undo and redo, validation, and ensuring the integrity of object relationships. Object persistence means that Core Data saves model objects to a persistent store and fetches them when required. The persistent store of a Core Data application—that is, the ultimate form in which object data is archived—can range from XML files to SQL databases. Core Data is ideally suited for applications that act as front ends for relational databases, but any Cocoa application can take advantage of its capabilities.&lt;/p&gt;  &lt;p&gt;The central concept of Core Data is the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_806"&gt;&lt;/a&gt;managed object. A managed object is simply a model object that is managed by Core Data, but it must be an instance of the &lt;code&gt;&lt;a href="http://developer.apple.com/library/ios/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html#//apple_ref/occ/cl/NSManagedObject"&gt;NSManagedObject&lt;/a&gt;&lt;/code&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_807"&gt;&lt;/a&gt; class or a subclass of that class. You describe the managed objects of your Core Data application using a schema called a&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_808"&gt;&lt;/a&gt;managed object model. (The Xcode application includes a data modeling tool to assist you in creating these schemas.) A managed object model contains descriptions of an application’s managed objects (also referred to as &lt;em&gt;entities&lt;/em&gt;). Each description specifies the attributes of an entity, its relationships with other entities, and metadata such as the names of the entity and the representing class.&lt;/p&gt;  &lt;p&gt;In a running Core Data application, an object known as a &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_809"&gt;&lt;/a&gt;&lt;em&gt;managed object context&lt;/em&gt; is responsible for a graph of managed objects. All managed objects in the graph must be registered with a managed object context. The context allows an application to add objects to the graph and remove them from it. It also tracks changes made to those objects, and thus can provide undo and redo support. When you’re ready to save changes made to managed objects, the managed object context ensures that those objects are in a valid state. When a Core Data application wants to retrieve data from its external data store, it sends a&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_810"&gt;&lt;/a&gt;fetch request—an object that specifies a set of criteria—to a managed object context. The managed object context returns the objects from the store that match the request after automatically registering them.&lt;/p&gt;  &lt;p&gt;A managed object context also functions as a gateway to an underlying collection of Core Data objects called the &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_811"&gt;&lt;/a&gt;&lt;em&gt;persistence stack&lt;/em&gt;. The persistence stack mediates between the objects in your application and external data stores. The stack consists of two different types of objects, &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_812"&gt;&lt;/a&gt;persistent stores and &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_813"&gt;&lt;/a&gt;persistent store coordinators. Persistent stores are at the bottom of the stack. They map between data in an external store—for example, an XML file—and corresponding objects in a managed object context. They don't interact directly with managed object contexts, however. Above a persistence store in the stack is a persistent store coordinator, which presents a facade to one or more managed object contexts so that multiple persistence stores below it appear as a single aggregate store. Figure 1-10 shows the relationships between objects in the Core Data architecture.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW89"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-10&lt;/strong&gt;&amp;#160; Examples of managed object contexts and the persistence stack&lt;img style="display: inline; float: right" alt="Managed object contexts and the persistence stack" align="right" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/advanced_persistence_stack.gif" width="370" height="396" /&gt;&lt;/p&gt;  &lt;p&gt;Core Data includes the &lt;code&gt;NSPersistentDocument&lt;/code&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_814"&gt;&lt;/a&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_815"&gt;&lt;/a&gt;class, a subclass of &lt;code&gt;NSDocument&lt;/code&gt; that helps to integrate Core Data and the document architecture. A persistent-document object creates its own persistence stack and managed object context, mapping the document to an external data store. An&lt;code&gt;NSPersistentDocument&lt;/code&gt; object provides default implementations of the &lt;code&gt;NSDocument&lt;/code&gt; methods for reading and writing document data.&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW54"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Other Frameworks with a Cocoa API&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As part of a standard installation, Apple includes, in addition to the core frameworks for both platforms, several frameworks that vend Cocoa programmatic interfaces. You can use these secondary frameworks to give your application capabilities that are desirable, if not essential. Some notable secondary frameworks include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_816"&gt;&lt;/a&gt;Sync Services—(Mac OS X only) Using Sync Services you can sync existing contacts, calendars and bookmarks schemas as well as your own application data. You can also extend existing schemas. See&lt;em&gt;Sync Services Programming Guide&lt;/em&gt; for more information.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_817"&gt;&lt;/a&gt;Address Book—This framework implements a centralized database for contact and other personal information. Applications that use the Address Book framework can share this contact information with other applications, including Apple’s Mail and iChat. See &lt;em&gt;Address Book Programming Guide for Mac OS X&lt;/em&gt; for more information.&lt;/p&gt;      &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW81"&gt;&lt;/a&gt;&lt;/p&gt;      &lt;p&gt;&lt;strong&gt;iOS Note:&lt;/strong&gt; There are different versions of this framework in Mac OS X and iOS. In addition, the Address Book framework in iOS has only ANSI C (procedural) programmatic interfaces.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_818"&gt;&lt;/a&gt;Preference Panes—(Mac OS X only) With this framework you can create plug-ins that your application dynamically loads to obtain a user interface for recording user preferences, either for the application itself or systemwide. See &lt;em&gt;Preference Pane Programming Guide&lt;/em&gt; for more information.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_819"&gt;&lt;/a&gt;Screen Saver—(Mac OS X only) The Screen Saver framework helps you create Screen Effects modules, which can be loaded and run via System Preferences. See &lt;em&gt;Screen Saver Framework Reference&lt;/em&gt; for more information.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_820"&gt;&lt;/a&gt;WebKit—(not public in iOS) The WebKit framework provides a set of core classes to display web content in windows, and by default, implements features such as following links clicked by the user. See &lt;em&gt;WebKit Objective-C Programming Guide&lt;/em&gt; for more information&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_821"&gt;&lt;/a&gt;.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;iAd—(iOS only) This framework allows your application to earn revenue by displaying advertisements to the user.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Map Kit—(iOS only) This framework lets an application embed maps into its own windows and views. It also supports map annotation, overlays, and reverse-geocoding lookups.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Event Kit—(iOS only) With the Event Kit framework, an application can access event information from a user’s Calendar database and enable users to create and edit events for their calendars. The framework also supports efficient fetching of event records, notifications of event changes, and automatic syncing with appropriate calendar databases.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Core Motion—(iOS only) The Core Motion processes low-level data received from a device’s accelerometer and gyroscope (if available) and presents that to applications for handling.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Core Location—(iOS only) Core Location lets an application determine the current location or heading associated with a device. With it an application can also define geographic regions and monitor when the user crosses the boundaries of those regions.&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;Media Player—(iOS only) This framework enables an application to play movies, music, audio podcasts, and audio book files. It also gives your application access to the iPod library.&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW12"&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;A Bit of History&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Many years ago Cocoa was known as &lt;a name="//apple_ref/doc/uid/TP40002974-CH3-DontLinkElementID_822"&gt;&lt;/a&gt;NeXTSTEP. NeXT Computer developed and released version 1.0 of NeXTSTEP in September of 1989, and versions 2.0 and 3.0 followed not far behind (in 1990 and 1992, respectively). In this early phase, NeXTSTEP was more than an application environment; the term referred to the entire operating system, including the windowing and imaging system (which was based on Display PostScript), the Mach kernel, device drivers, and so on.&lt;/p&gt;  &lt;p&gt;Back then, there was no Foundation framework. Indeed, there were no frameworks; instead, the software libraries (dynamically shared) were known as &lt;em&gt;kits&lt;/em&gt;, the most prominent of them being Application Kit. Much of the role that Foundation now occupies was taken by an assortment of functions, structures, constants, and other types. Application Kit itself had a much smaller set of classes than it does today.Figure 1-11 shows a class hierarchy chart of NeXTSTEP 0.9 (1988).&lt;/p&gt;  &lt;p&gt;&lt;a name="//apple_ref/doc/uid/TP40002974-CH3-SW8"&gt;&lt;/a&gt;&lt;strong&gt;Figure 1-11&lt;/strong&gt;&amp;#160; Application Kit class hierarchy in 1988&lt;img style="display: inline; float: right" alt="Application Kit class hierarchy in 1988" align="right" src="http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CocoaFundamentals/Art/appkitc_88.gif" width="617" height="310" /&gt;&lt;/p&gt;  &lt;p&gt;In addition to Application Kit, the early NeXTSTEP included the Sound Kit and the Music Kit, libraries containing a rich set of Objective-C classes that provided high-level access to the Display Postscript layer for audio and music synthesis.&lt;/p&gt;  &lt;p&gt;In early 1993, NeXTSTEP 3.1 was ported to (and shipped on) Intel, Sparc, and Hewlett-Packard computers. NeXTSTEP 3.3 also marked a major new direction, for it included a preliminary version of Foundation. Around this time (1993), the OpenStep initiative also took form. OpenStep was a collaboration between Sun and NeXT to port the higher levels of NeXTSTEP (particularly Application Kit and Display PostScript) to Solaris. The “Open” in the name referred to the open API specification that the companies would publish jointly. The official OpenStep API, published in September of 1994, was the first to split the API between Foundation and Application Kit and the first to use the “NS” prefix. Eventually, Application Kit became known as, simply, AppKit.&lt;/p&gt;  &lt;p&gt;By June 1996, NeXT had ported and shipped versions of OpenStep 4.0 that could run Intel, Sparc, and Hewlett-Packard computers as well as an OpenStep runtime that could run on Windows systems. Sun also finished their port of OpenStep to Solaris and shipped it as part of their Network Object Computing Environment. OpenStep, however, never became a significant part of Sun’s overall strategy.&lt;/p&gt;  &lt;p&gt;When Apple acquired NeXT Software (as it was then called) in 1997, OpenStep became the Yellow Box and was included with Mac OS X Server (also known as Rhapsody) and Windows. Then, with the evolution of the Mac OS X strategy, it was finally renamed to “Cocoa.”&lt;/p&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2470166.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2012/04/25/2470166.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/kkun/archive/2012/01/30/2332309.html</id><title type="text">Javascript小技巧,去掉小数位并且不会四舍五入</title><summary type="text">1: var n3 = 52.3685; 2: document.writeln(n3 &gt;&gt; 0);// 52 3: 可以去掉小数。如上代码,就是这么简单右移位操作导致小数部分丢失,为何会这样呢?左移位可以吗?移位操作是否都有如此功能呢?带着疑问又写了一段代码用来测试以上想法,继续上代码 1: { 2: n = 52.123456; 3: //...</summary><published>2012-01-30T09:53:00Z</published><updated>2012-01-30T09:53:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2012/01/30/2332309.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2012/01/30/2332309.html"/><content type="html">&lt;div class="csharpcode"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;var&lt;/span&gt; n3 = 52.3685;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;document.writeln(n3 &amp;gt;&amp;gt; 0);&lt;span class="rem"&gt;// 52&lt;/span&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;可以去掉小数。&lt;/div&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;p&gt;如上代码,就是这么简单&lt;/p&gt;&lt;p&gt;右移位操作导致小数部分丢失,为何会这样呢?左移位可以吗?移位操作是否都有如此功能呢?&lt;/p&gt;&lt;p&gt;带着疑问又写了一段代码用来测试以上想法,继续上代码&lt;/p&gt;&lt;div class="csharpcode"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;{&lt;span class="lnum"&gt;   2:  &lt;/span&gt;    n = 52.123456;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="rem"&gt;//alert(typeof n);&lt;/span&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    alert(n);&lt;span class="lnum"&gt;   5:  &lt;/span&gt;}&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&lt;span class="rem"&gt;//有符号右移&lt;/span&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;{&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    n = 52.123456;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="kwrd"&gt;var&lt;/span&gt; n2 = n &amp;gt;&amp;gt; 0;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="rem"&gt;//alert(typeof n2);&lt;/span&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    alert(n2);&lt;span class="lnum"&gt;  12:  &lt;/span&gt;}&lt;span class="lnum"&gt;  13:  &lt;/span&gt;&lt;span class="rem"&gt;//无符号右移&lt;/span&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;{&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    n = 52.123456;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    &lt;span class="kwrd"&gt;var&lt;/span&gt; n3 = n &amp;gt;&amp;gt;&amp;gt; 0;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    &lt;span class="rem"&gt;//alert(typeof n3);&lt;/span&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    alert(n3);&lt;span class="lnum"&gt;  19:  &lt;/span&gt;}&lt;span class="lnum"&gt;  20:  &lt;/span&gt;&lt;span class="rem"&gt;//左移0位&lt;/span&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;{&lt;span class="lnum"&gt;  22:  &lt;/span&gt;    n = 52.123456;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;    &lt;span class="kwrd"&gt;var&lt;/span&gt; n4 = n &amp;lt;&amp;lt; 0;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;    &lt;span class="rem"&gt;//alert(typeof n4);&lt;/span&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;    alert(n4);&lt;span class="lnum"&gt;  26:  &lt;/span&gt;}&lt;span class="lnum"&gt;  27:  &lt;/span&gt;&lt;span class="rem"&gt;//按位或or&lt;/span&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;{&lt;span class="lnum"&gt;  29:  &lt;/span&gt;    n = 52.123456;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;    &lt;span class="kwrd"&gt;var&lt;/span&gt; n5 = n | 0;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;    &lt;span class="rem"&gt;//alert(typeof n5);&lt;/span&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;    alert(n5);&lt;span class="lnum"&gt;  33:  &lt;/span&gt;}&lt;span class="lnum"&gt;  34:  &lt;/span&gt;&lt;span class="rem"&gt;//按位异或xor&lt;/span&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;{&lt;span class="lnum"&gt;  36:  &lt;/span&gt;    n = 52.123456;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;    &lt;span class="kwrd"&gt;var&lt;/span&gt; n6 = n ^ 0;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;    &lt;span class="rem"&gt;//alert(typeof n6);&lt;/span&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;    alert(n6);&lt;span class="lnum"&gt;  40:  &lt;/span&gt;}&lt;/div&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;p&gt;那,这里不卖关子,直接给出测试结果来:以上五种方法均可以去掉小数点;然而为什么会这样呢?&lt;br&gt;翻翻EAMCScript规范吧,或许里边会有答案,见&lt;a href="http://bclary.com/2004/11/07/#a-9.5"&gt;http://bclary.com/2004/11/07/#a-9.5&lt;/a&gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a name="a-11.7.1"&gt;&lt;u&gt;先来看看位操作都做了什么,下边是位操作的实现步骤,重点在第五,第六步&lt;/u&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;11.7.1 The Left Shift Operator (&amp;lt;&amp;lt; )&lt;/b&gt;&lt;p&gt;Performs a bitwise left shift operation on the left operand by the amount specified by the right operand.&lt;p&gt;The production &lt;i&gt;ShiftExpression&lt;/i&gt; &lt;b&gt;:&lt;/b&gt; &lt;i&gt;ShiftExpression&lt;/i&gt; &lt;b&gt;&amp;lt;&amp;lt;&lt;/b&gt; &lt;i&gt;AdditiveExpression&lt;/i&gt; is evaluated as follows:&lt;p&gt;1. Evaluate &lt;i&gt;ShiftExpression&lt;/i&gt;.&lt;p&gt;2.Call &lt;a href="http://bclary.com/2004/11/07/#a-8.7.1"&gt;GetValue&lt;/a&gt;(Result(1)).&lt;p&gt;3.Evaluate &lt;i&gt;AdditiveExpression&lt;/i&gt;.&lt;p&gt;4. Call &lt;a href="http://bclary.com/2004/11/07/#a-8.7.1"&gt;GetValue&lt;/a&gt;(Result(3)).&lt;p&gt;&lt;b&gt;&lt;font style="" color="#ff0000"&gt;5.Call &lt;/font&gt;&lt;a href="http://bclary.com/2004/11/07/#a-9.5"&gt;&lt;font style="" color="#ff0000"&gt;ToInt32&lt;/font&gt;&lt;/a&gt;&lt;font style="" color="#ff0000"&gt;(Result(2)).&lt;/font&gt;&lt;/b&gt;&lt;p&gt;&lt;b&gt;&lt;font style="" color="#ff0000"&gt;6.Call &lt;/font&gt;&lt;a href="http://bclary.com/2004/11/07/#a-9.6"&gt;&lt;font style="" color="#ff0000"&gt;ToUint32&lt;/font&gt;&lt;/a&gt;&lt;font style="" color="#ff0000"&gt;(Result(4)).&lt;/font&gt;&lt;/b&gt;&lt;p&gt;7.Mask out all but the least significant 5 bits of Result(6), that is, compute Result(6) &amp;amp; 0x1F.&lt;p&gt;8.Left shift Result(5) by Result(7) bits. The result is a signed 32 bit integer.&lt;p&gt;9.Return Result(8).|&lt;br&gt;&lt;br&gt;&lt;u&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;u&gt;再来看看那锅ToInt32干了什么,重点在第三步&lt;/u&gt;&lt;br&gt;&lt;a name="a-9.5"&gt;&lt;b&gt;9.5&lt;/b&gt;&lt;/a&gt;&lt;b&gt; ToInt32: (Signed 32 Bit Integer)&lt;/b&gt;&lt;/p&gt;&lt;p&gt;The operator ToInt32 converts its argument to one of 2&lt;sup&gt;32&lt;/sup&gt; integer values in the range -2&lt;sup&gt;31&lt;/sup&gt; through 2&lt;sup&gt;31&lt;/sup&gt;-1, inclusive. This operator functions as follows:&lt;p&gt;1. Call &lt;a href="http://bclary.com/2004/11/07/#a-9.3"&gt;ToNumber&lt;/a&gt; on the input argument.&lt;p&gt;2. If Result(1) is &lt;b&gt;NaN, +0, -0, +∞&lt;/b&gt;, or &lt;b&gt;-∞&lt;/b&gt;, return +0.&lt;p&gt;&lt;b&gt;&lt;u&gt;&lt;font color="#000000"&gt;3. Compute sign(Result(1)) * &lt;font color="#ff0000"&gt;floor(abs(Result(1))&lt;/font&gt;).&lt;/font&gt;&lt;/u&gt;&lt;/b&gt;&lt;p&gt;4. Compute Result(3) modulo 2&lt;sup&gt;32&lt;/sup&gt; ; that is, a finite integer value k of Number type with positive sign and less than 2&lt;sup&gt;32&lt;/sup&gt; in magnitude such the mathematical difference of Result(3) and k is mathematically an integer multiple of 2&lt;sup&gt;32&lt;/sup&gt; .&lt;p&gt;5. If Result(4) is greater than or equal to 2&lt;sup&gt;31&lt;/sup&gt; , return Result(4)-2&lt;sup&gt;32&lt;/sup&gt; , otherwise return Result(4).&lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;u&gt;最后来看那个floor是什么意思,这里重点看第三步的后半拉,就是那个floor是干什么滴&lt;/u&gt;&lt;p&gt;&lt;i&gt;&lt;font style="background-color: #ffff00"&gt;floor(x) = x-(x modulo 1)&lt;/font&gt;&lt;/i&gt;&lt;p&gt;看见没,就在这一步把小数干掉了&lt;p&gt;Floor(x) 等于x减去x模上1&lt;p&gt;即&lt;p&gt;N= 52.123456 – 52.123456%1&lt;p&gt;=52.123456-0.1234559999999&lt;p&gt;=52&lt;p&gt;&amp;nbsp; &lt;p&gt;&lt;u&gt;搜代斯呐,春节快乐~&lt;/u&gt;&lt;p&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2332309.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2012/01/30/2332309.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/kkun/archive/2012/01/06/2314885.html</id><title type="text">javascript中的封装多态和继承</title><summary type="text">封装Encapsulation 如下代码,这就算是封装了 (function (windows, undefined) { var i = 0;//相对外部环境来说,这里的i就算是封装了 })(window, undefined);继承Inheritance (function (windows, undefined) { //父类 function ...</summary><published>2012-01-06T08:48:00Z</published><updated>2012-01-06T08:48:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2012/01/06/2314885.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2012/01/06/2314885.html"/><content type="html">&lt;p&gt;&lt;font color="#ff0000" size="4"&gt;&lt;strong&gt;封装Encapsulation&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;如下代码,这就算是封装了&lt;/p&gt;  &lt;div class="csharpcode"&gt;   (&lt;span class="kwrd"&gt;function&lt;/span&gt; (windows, undefined) {      &lt;span class="kwrd"&gt;var&lt;/span&gt; i = 0;&lt;span class="rem"&gt;//相对外部环境来说,这里的i就算是封装了&lt;/span&gt;  })(window, undefined);&lt;/div&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;font color="#ff0000" size="4"&gt;&lt;strong&gt;继承Inheritance&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;div class="csharpcode"&gt;  (&lt;span class="kwrd"&gt;function&lt;/span&gt; (windows, undefined) {      &lt;span class="rem"&gt;//父类&lt;/span&gt;      &lt;span class="kwrd"&gt;function&lt;/span&gt; Person() { }      Person.prototype.name = &lt;span class="str"&gt;&amp;quot;name in Person&amp;quot;&lt;/span&gt;;  &amp;#160;      &lt;span class="rem"&gt;//子类&lt;/span&gt;      &lt;span class="kwrd"&gt;function&lt;/span&gt; Student() { }      Student.prototype = &lt;span class="kwrd"&gt;new&lt;/span&gt; Person();           &lt;span class="rem"&gt;//修复原型&lt;/span&gt;      Student.prototype.constructor = Student;    &lt;span class="rem"&gt;//构造函数&lt;/span&gt;      Student.prototype.supr = Person.prototype;  &lt;span class="rem"&gt;//父类&lt;/span&gt;  &amp;#160;      &lt;span class="rem"&gt;//创建子类实例&lt;/span&gt;      &lt;span class="kwrd"&gt;var&lt;/span&gt; stu = &lt;span class="kwrd"&gt;new&lt;/span&gt; Student();      Student.prototype.age = 28;      Student.prototype.supr.name = &lt;span class="str"&gt;&amp;quot;name in Student instance&amp;quot;&lt;/span&gt;;  &amp;#160;      &lt;span class="rem"&gt;//打印子类成员及父类成员&lt;/span&gt;      alert(stu.name); &lt;span class="rem"&gt;//name in Student instance&lt;/span&gt;      alert(stu.supr.name); &lt;span class="rem"&gt;//name in Person&lt;/span&gt;      alert(stu.age); &lt;span class="rem"&gt;//28&lt;/span&gt;  &amp;#160;  })(window, undefined);&lt;/div&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;p&gt;&lt;font color="#ff0000" size="4"&gt;&lt;strong&gt;多态Polymorphism&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;有了继承,多态就好办了&lt;/p&gt;&lt;div class="csharpcode"&gt;  &lt;span class="rem"&gt;//这就是继承了&lt;/span&gt;  (&lt;span class="kwrd"&gt;function&lt;/span&gt; (windows, undefined) {      &lt;span class="rem"&gt;//父类&lt;/span&gt;      &lt;span class="kwrd"&gt;function&lt;/span&gt; Person() { }      Person.prototype.name = &lt;span class="str"&gt;&amp;quot;name in Person&amp;quot;&lt;/span&gt;;      Person.prototype.learning = &lt;span class="kwrd"&gt;function&lt;/span&gt; () {          alert(&lt;span class="str"&gt;&amp;quot;learning in Person&amp;quot;&lt;/span&gt;)      }  &amp;#160;      &lt;span class="rem"&gt;//子类&lt;/span&gt;      &lt;span class="kwrd"&gt;function&lt;/span&gt; Student() { }      Student.prototype = &lt;span class="kwrd"&gt;new&lt;/span&gt; Person();           &lt;span class="rem"&gt;//修复原型&lt;/span&gt;      Student.prototype.constructor = Student;    &lt;span class="rem"&gt;//构造函数&lt;/span&gt;      Student.prototype.supr = Person.prototype;  &lt;span class="rem"&gt;//父类&lt;/span&gt;      Student.prototype.learning = &lt;span class="kwrd"&gt;function&lt;/span&gt; () {          alert(&lt;span class="str"&gt;&amp;quot;learning in Student&amp;quot;&lt;/span&gt;);      }  &amp;#160;      &lt;span class="rem"&gt;//工人&lt;/span&gt;      &lt;span class="kwrd"&gt;function&lt;/span&gt; Worker() { }      Worker.prototype = &lt;span class="kwrd"&gt;new&lt;/span&gt; Person();           &lt;span class="rem"&gt;//修复原型&lt;/span&gt;      Worker.prototype.constructor = Worker;    &lt;span class="rem"&gt;//构造函数&lt;/span&gt;      Worker.prototype.supr = Person.prototype;  &lt;span class="rem"&gt;//父类&lt;/span&gt;      Worker.prototype.learning = &lt;span class="kwrd"&gt;function&lt;/span&gt; () {          alert(&lt;span class="str"&gt;&amp;quot;learning in Worker&amp;quot;&lt;/span&gt;);      }  &amp;#160;      &lt;span class="rem"&gt;//工厂&lt;/span&gt;      &lt;span class="kwrd"&gt;var&lt;/span&gt; personFactory = &lt;span class="kwrd"&gt;function&lt;/span&gt; (type) {          &lt;span class="kwrd"&gt;switch&lt;/span&gt; (type) {              &lt;span class="kwrd"&gt;case&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;Worker&amp;quot;&lt;/span&gt;:                  &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Worker();                  &lt;span class="kwrd"&gt;break&lt;/span&gt;;              &lt;span class="kwrd"&gt;case&lt;/span&gt; &lt;span class="str"&gt;&amp;quot;Student&amp;quot;&lt;/span&gt;:                  &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Student();                  &lt;span class="kwrd"&gt;break&lt;/span&gt;;          }          &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Person();      }  &amp;#160;      &lt;span class="rem"&gt;//客户端&lt;/span&gt;      &lt;span class="kwrd"&gt;var&lt;/span&gt; person = personFactory(&lt;span class="str"&gt;&amp;quot;Student&amp;quot;&lt;/span&gt;);      person.learning(); &lt;span class="rem"&gt;//learning in Student&lt;/span&gt;      person = personFactory(&lt;span class="str"&gt;&amp;quot;Worker&amp;quot;&lt;/span&gt;);      person.learning(); &lt;span class="rem"&gt;//learning in Worker&lt;/span&gt;  &amp;#160;  })(window, undefined);&lt;/div&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2314885.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2012/01/06/2314885.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/kkun/archive/2011/12/15/2288744.html</id><title type="text">[转载]我想和你一起吃晚餐</title><summary type="text">父亲下班回家已经很晚了，身体疲倦、心情也不太好。这时，他发现5岁的儿子正靠在门边等他。 “我可以问你一个问题吗？”儿子问。 “什么问题？”父亲有些不耐烦。 “爸，你1小时能挣多少钱？” “这与你无关。为什么要问这样的问题？”父亲生气地说。 “我只是想知道。”儿子望着父亲，恳求道：“请告诉我，你1小时挣多少钱？” “假如你一定要知道的话，那我就告诉你吧。我1小时挣20美元。”...</summary><published>2011-12-15T05:16:00Z</published><updated>2011-12-15T05:16:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2011/12/15/2288744.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2011/12/15/2288744.html"/><content type="html">&lt;p&gt;父亲下班回家已经很晚了，身体疲倦、心情也不太好。这时，他发现5岁的儿子正靠在门边等他。&lt;/p&gt;  &lt;p&gt; “我可以问你一个问题吗？”儿子问。&lt;/p&gt;  &lt;p&gt; “什么问题？”父亲有些不耐烦。&lt;/p&gt;  &lt;p&gt; “爸，你1小时能挣多少钱？”&lt;/p&gt;  &lt;p&gt; “这与你无关。为什么要问这样的问题？”父亲生气地说。&lt;/p&gt;  &lt;p&gt; “我只是想知道。”儿子望着父亲，恳求道：“请告诉我，你1小时挣多少钱？”&lt;/p&gt;  &lt;p&gt; “假如你一定要知道的话，那我就告诉你吧。我1小时挣20美元。”父亲有点按捺不住了。&lt;/p&gt;  &lt;p&gt; “喔。”儿子沮丧地低下头。过了一会儿，他又抬起头，犹犹豫豫地说：“爸——，可以借给我10美元吗？”&lt;/p&gt;  &lt;p&gt; 父亲终于发怒了：“如果问这种问题就是想要向我借钱去买毫无意义的玩具，那你还是回房间去，躺到床上好好想想为什么你会那么自私。我每天长时间辛苦工作，现在需要休息，没时间和你玩小孩子的游戏。”&lt;/p&gt;  &lt;p&gt; 儿子一声不吭地走回自己的房间，轻轻关上了门。&lt;/p&gt;  &lt;p&gt; 儿子走后，父亲还在生气。过了一阵儿，他渐渐平静下来。想到自己刚才有些粗暴，他走进孩子的房间，轻声问：“你睡了吗？”&lt;/p&gt;  &lt;p&gt; “爸，还没呢。我还醒着。”儿子回答道。&lt;/p&gt;  &lt;p&gt; “爸爸今天心情不太好，所以刚才可能对你太凶了，”父亲说，“——这是你要的10美元。”“爸，谢谢你。”儿子欣喜地接过钱，然后又从枕头下拿出一些皱皱的钞票，仔细地数起来。&lt;/p&gt;  &lt;p&gt; “你已经有钱了为什么还要？”父亲又开始生气了。&lt;/p&gt;  &lt;p&gt; “因为只有那些还不够，不过现在足够了。”儿子回答道。然后他将数好的钱全部放在父亲手里，认真地说：“爸，我现在有20美元了，我可以向你买一个小时的时间吗？明天请早一点回家，我想和你一起吃晚餐。”&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;A man came home from work late tired and irritated to find his5-year-old son waiting for him at the door.&lt;/p&gt;  &lt;p&gt;Daddy, may I ask you a question?&lt;/p&gt;  &lt;p&gt;Yes, sure, what is it? Replied the man.&lt;/p&gt;  &lt;p&gt;Daddy, how much do you make an hour?&lt;/p&gt;  &lt;p&gt;That’s none of you business, why do you ask such a thing? The man said angrily.&lt;/p&gt;  &lt;p&gt;I just want to know, please tell me. How much do you make an hour? Pleeaded The little boy.&lt;/p&gt;  &lt;p&gt;If you must know, I make 20 dollars an hour.&lt;/p&gt;  &lt;p&gt;“Oh”, the little boy replied with head down. Looking up he said: daddy, may I please borrow 10 dollars.&lt;/p&gt;  &lt;p&gt;The father was furious. If you only reason you asked that so you can borrow some money to buy a silly toy or some other nonsense, then you march yourself straight to your room and go to bed. Think about why you being so selfish. I work hard every day for such childish behavior.&lt;/p&gt;  &lt;p&gt;The little boy quitely went to his room and shut the door.&lt;/p&gt;  &lt;p&gt;The man sat down and started to even angrier about the little boy’s questions. How dare you ask such a question only to get some money. After about an hour or so, the man has calmed down and started to think. Maybe there’s something he really needed to buy with that 10 dollars, and he really didn’t ask for money very often.&lt;/p&gt;  &lt;p&gt;The man went to the door the little boy’s room and opened the door.&lt;/p&gt;  &lt;p&gt;Are you sleep, son? He asked.&lt;/p&gt;  &lt;p&gt;No, daddy, I’m awake. Replied the boy.&lt;/p&gt;  &lt;p&gt;I have been thinking may be I was too hard on you earlier. Say the man. It’s been a long day, and I took out my aggravation on you, here is the 10 dollars you asked for.&lt;/p&gt;  &lt;p&gt;The little boy sat straight up, smiling.&lt;/p&gt;  &lt;p&gt;Oh, thank you, daddy. He yelled. Then reaching under his pillow, he pulled out some crumble up bills. The man seeing the boy already had money, started to get angry again.&lt;/p&gt;  &lt;p&gt;The little boy slowly counts about his money then look up at his father.&lt;/p&gt;  &lt;p&gt;Why do you want more money if you already had some. The father grumbled.&lt;/p&gt;  &lt;p&gt;Because I didn’t have enough, but now I do. For little boy reply.&lt;/p&gt;  &lt;p&gt;Daddy, I have 20 dollars now, can I borrow an hour your time, please come home early tomorrow. I would like to have dinner with you.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;直接转载自 &lt;a href="http://sjzflps.jjtang.com/blog/blog-htm-do-read-uid-681206-tid-628328.html"&gt;http://sjzflps.jjtang.com/blog/blog-htm-do-read-uid-681206-tid-628328.html&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2288744.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2011/12/15/2288744.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/kkun/archive/2011/12/05/2276411.html</id><title type="text">经典排序算法 - 图书馆排序(Library Sort)</title><summary type="text">经典排序算法 - 图书馆排序(Library Sort) 思路简介,大概意思是说,排列图书时,如果在每本书之间留一定的空隙,那么在进行插入时就有可能会少移动一些书,说白了就是在插入排序的基础上,给书与书之间留一定的空隙,这个空隙越大,需要移动的书就越少,这是它的思路,用空间换时间 看红线标的那句话知道,这个空隙留多大,你自己定 图书馆排序的关键是分配空间,分配完空间后直接使用插入排序即可 ...</summary><published>2011-12-05T02:01:00Z</published><updated>2011-12-05T02:01:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2011/12/05/2276411.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2011/12/05/2276411.html"/><content type="html">&lt;p&gt;&lt;b&gt;经典排序算法 - 图书馆排序(Library Sort)&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;思路简介,大概意思是说,排列图书时,如果在每本书之间留一定的空隙,那么在进行插入时就有可能会少移动一些书,说白了就是在插入排序的基础上,给书与书之间留一定的空隙,这个空隙越大,需要移动的书就越少,这是它的思路,用空间换时间&lt;/p&gt;  &lt;p&gt;看红线标的那句话知道,这个空隙留多大,你自己定&lt;/p&gt;  &lt;p&gt;图书馆排序的关键是分配空间,分配完空间后直接使用插入排序即可&lt;/p&gt;  &lt;p&gt;&lt;a href="http://images.cnblogs.com/cnblogs_com/kkun/201112/201112051000515224.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Image(4)" border="0" alt="Image(4)" src="http://images.cnblogs.com/cnblogs_com/kkun/201112/201112051000557369.png" width="919" height="242" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;进行空间分配的过程&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;这个我实在是找不到相关的资料,没准就是平均分配嘞&lt;/p&gt;  &lt;p&gt;&lt;b&gt;进行插入排序的过程&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;举例待排数组[ &lt;u&gt;0 0 6&lt;/u&gt; &lt;u&gt;0 0 2&lt;/u&gt; &lt;u&gt;0 0 4&lt;/u&gt; &lt;u&gt;0 0 1&lt;/u&gt; &lt;u&gt;0 0 5&lt;/u&gt; &lt;u&gt;0 0 9&lt;/u&gt; ],直接对它进行&lt;u&gt;插入排序&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;第一次移动,直接把2放6前边&lt;/p&gt;  &lt;p&gt;[ 0 2 6 0 0 0 0 0 4 0 0 1 0 0 5 0 0 9 ]&lt;/p&gt;  &lt;p&gt;第二次移动,先把6往后挪,然后把4放在刚才6的位置,移动了一个位置&lt;/p&gt;  &lt;p&gt;[ 0 2 4 6 0 0 0 0 0 0 0 1 0 0 5 0 0 9 ]&lt;/p&gt;  &lt;p&gt;第三次移动,直接把1放2前边&lt;/p&gt;  &lt;p&gt;[ 1 2 4 6 0 0 0 0 0 0 0 0 0 0 5 0 0 9 ]&lt;/p&gt;  &lt;p&gt;第四次移动,再把6往后挪一位,把5放在刚才6的位置&lt;/p&gt;  &lt;p&gt;[ 1 2 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 9 ]&lt;/p&gt;  &lt;p&gt;第五次移动后,把9放6后边,排序结束&lt;/p&gt;  &lt;p&gt;[ 1 2 4 5 6 9 0 0 0 0 0 0 0 0 0 0 0 0 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2011/11/23/2260312.html"&gt;返回主目录 [经典排序算法][集锦]&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;reference&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.cs.sunysb.edu/~bender/newpub/BenderFaMo06-librarysort.pdf"&gt;http://www.cs.sunysb.edu/~bender/newpub/BenderFaMo06-librarysort.pdf&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://zhangyu8374.iteye.com/blog/86317"&gt;http://zhangyu8374.iteye.com/blog/86317&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.cnblogs.com/richselian/archive/2011/09/16/2179152.html"&gt;http://www.cnblogs.com/richselian/archive/2011/09/16/2179152.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://algorithm.l918.net/forum.php?mod=viewthread&amp;amp;tid=19"&gt;http://algorithm.l918.net/forum.php?mod=viewthread&amp;amp;tid=19&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.softpanorama.org/Algorithms/Sorting/insertion_sort.shtml"&gt;http://www.softpanorama.org/Algorithms/Sorting/insertion_sort.shtml&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2276411.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2011/12/05/2276411.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry><entry><id>http://www.cnblogs.com/kkun/archive/2011/11/28/2266559.html</id><title type="text">经典排序算法 - 圈排序Cycle Sort</title><summary type="text">经典排序算法 - Cycle Sort Cycle sort的思想与计数排序太像了,理解了基数排序再看这个会有很大的帮助, 圈排序与计数排序的区别在于圈排序只给那些需要计数的数字计数,先看完文章吧,看完再回来理解这一句话 所谓的圈的定义,我只能想到用例子来说明,实在不好描述 待排数组[ 6 2 4 1 5 9 ] 排完序后[ 1 2 4 5 6 9 ] 数组索引[ 0 1 2 3 4 ...</summary><published>2011-11-28T09:50:00Z</published><updated>2011-11-28T09:50:00Z</updated><author><name>kkun</name><uri>http://www.cnblogs.com/kkun/</uri></author><link rel="alternate" href="http://www.cnblogs.com/kkun/archive/2011/11/28/2266559.html"/><link rel="alternate" type="text/html" href="http://www.cnblogs.com/kkun/archive/2011/11/28/2266559.html"/><content type="html">&lt;p&gt;&lt;b&gt;经典排序算法 - Cycle Sort&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;Cycle sort的思想与&lt;a href="http://www.cnblogs.com/kkun/archive/2011/11/23/2260299.html"&gt;计数排序&lt;/a&gt;太像了,理解了基数排序再看这个会有很大的帮助,&lt;/p&gt;  &lt;p&gt;&lt;u&gt;圈排序与计数排序的区别在于圈排序只给那些需要计数的数字计数,先看完文章吧,看完再回来理解这一句话&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;所谓的圈的定义,我只能想到用例子来说明,实在不好描述&lt;/p&gt;  &lt;p&gt;待排数组[ 6 2 4 1 5 9 ]&lt;/p&gt;  &lt;p&gt;排完序后[ 1 2 4 5 6 9 ]&lt;/p&gt;  &lt;p&gt;数组索引[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;第一部分&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 第一步,我们现在来观察待排数组和排完后的结果,以及待排数组的索引,可以发现&lt;/p&gt;  &lt;p&gt;排完序后的6应该出现在索引4的位置上,而它现在却在位置0上,&lt;/p&gt;  &lt;p&gt;记住这个位置啊,一直找到某个数应该待在位置0上我们的任务就完成了&lt;/p&gt;  &lt;p&gt;待排数组[ 6 2 4 1 5 9 ]&lt;/p&gt;  &lt;p&gt;排完序后[ 1 2 4 5 6 9 ]&lt;/p&gt;  &lt;p&gt;数组索引[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 第二步,而待排数组索引4位置上的5应该出现在索引3的位置上&lt;/p&gt;  &lt;p&gt;待排数组[ 6 2 4 1 5 9 ]&lt;/p&gt;  &lt;p&gt;排完序后[ 1 2 4 5 6 9 ]&lt;/p&gt;  &lt;p&gt;数组索引[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 第三步,同样的,待排数组索引3的位置是1,1应该出现在位置0上,注意注意,找到这么一个数了:1,它应该待在位置0上&lt;/p&gt;  &lt;p&gt;待排数组[ 6 2 4 1 5 9 ]&lt;/p&gt;  &lt;p&gt;排完序后[ 1 2 4 5 6 9 ]&lt;/p&gt;  &lt;p&gt;数组索引[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 第四步,而索引0处却放着6,而6应该出现在索引4的位置,至此可以发现,回到原点了,问题回到第一步了,&lt;/p&gt;  &lt;p&gt;所以这里并不存在所谓的第四步,前三步就已经转完一圈了&lt;/p&gt;  &lt;p&gt;待排数组[ 6 2 4 1 5 9 ]&lt;/p&gt;  &lt;p&gt;排完序后[ 1 2 4 5 6 9 ]&lt;/p&gt;  &lt;p&gt;数组索引[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;这就是所谓的一圈!真不好描述,不知道您看明白没...汗.&lt;/p&gt;  &lt;p&gt;前三步转完一圈,得到的数据分别是[ 6 5 1 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;第二部分&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 第一步,圈排序并不是一圈排序,而一圈或多圈排序,所以,还得继续找,这一步从第二个数字2处开始转圈&lt;/p&gt;  &lt;p&gt;待排中的2位于索引1处,排序完毕仍然处于位置1位置,所以这一圈完毕,得到圈数据[ 2 ]&lt;/p&gt;  &lt;p&gt;待排数组[ 6 2 4 1 5 9 ]&lt;/p&gt;  &lt;p&gt;排完序后[ 1 2 4 5 6 9 ]&lt;/p&gt;  &lt;p&gt;数组索引[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;第三部分&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 第一步,同上,4也出现了它应该待的位置,结束这一圈,得到第三个圈:[ 4 ]&lt;/p&gt;  &lt;p&gt;待排数组[ 6 2 4 1 5 9 ]&lt;/p&gt;  &lt;p&gt;排完序后[ 1 2 4 5 6 9 ]&lt;/p&gt;  &lt;p&gt;数组索引[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;第四部分&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; 第一步,由于1和5出现在第一圈里,这是什么意思呢,说明这两个数已经有自己的圈子了,不用再找了,&lt;/p&gt;  &lt;p&gt;即是找,最后还是得到第一圈的数据[ 6 5 1 ],所以,1和5跳过,这一部分实际应该找的是9,来看看9的圈子&lt;/p&gt;  &lt;p&gt;9应该出现在索引5的位置,实际上它就在索引5的位置,与第二部分的第一步的情况一样,所以这一圈的数据也出来了:[ 9 ]&lt;/p&gt;  &lt;p&gt;待排数组[ 6 2 4 1 5 9 ]&lt;/p&gt;  &lt;p&gt;排完序后[ 1 2 4 5 6 9 ]&lt;/p&gt;  &lt;p&gt;数组索引[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;一共找到四个圈子,分别是&lt;/p&gt;  &lt;p&gt;[ 6 5 1 ] , [ 2 ] ,[ 4 ] , [ 9 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;如果一个圈只有一个数字,那么它是不需要转圈的,即不需要排序,那么只有第一个圈排序即可&lt;/p&gt;  &lt;p&gt;你可能要问了,前边的那些圈子都是基于已知排序结果才能得到,我都已知结果还排个毛啊&lt;/p&gt;  &lt;p&gt;以上内容都是为了说明什么是圈,知道什么是圈后才能很好的理解圈排序&lt;/p&gt;  &lt;p&gt;现在来分解排序的细节&lt;/p&gt;  &lt;p&gt;第一步,将6取出来,计算出有4个数字比6小,将6放入索引4,同时原索引4位置的数字5出列&lt;/p&gt;  &lt;p&gt;排序之前[ 0 2 4 1 5 9 ] 6&lt;/p&gt;  &lt;p&gt;排序之后[ 0 2 4 1 6 9 ] 5&lt;/p&gt;  &lt;p&gt;索引位置[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;第二步,当前数字5,计算出有3个数字比5小,将5放入索引3,同时原索引3位置的数字&lt;/p&gt;  &lt;p&gt;排序之前[ 0 2 4 1 6 9 ] 5&lt;/p&gt;  &lt;p&gt;排序之后[ 0 2 4 5 6 9 ] 1&lt;/p&gt;  &lt;p&gt;索引位置[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;第三步,当前数字1,计算出有0个数字比1小,将1放入索引0,索引0处为空,这圈完毕&lt;/p&gt;  &lt;p&gt;排序之前[ 0 2 4 5 6 9 ] 1&lt;/p&gt;  &lt;p&gt;排序之后[ 1 2 4 5 6 9 ]&lt;/p&gt;  &lt;p&gt;索引位置[ 0 1 2 3 4 5 ]&lt;/p&gt;  &lt;p&gt;第一个圈[ 6 5 1 ]完毕&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;第四步,取出下一个数字2,计算出有1个数字比2小,将2放入索引1处,发现它本来就在索引1处&lt;/p&gt;  &lt;p&gt;第五步,取出下一个数字4,计算出有2个数字比4小,将4放入索引2处,发现它本来就在索引2处&lt;/p&gt;  &lt;p&gt;第六步,取出下一个数字5,5在第一个圈内,不必排序&lt;/p&gt;  &lt;p&gt;第七步,取出下一个数字6,6在第一个圈内,不必排序&lt;/p&gt;  &lt;p&gt;第八步,取出下一个数字9,计算出有5个数字比9小,将9放入索引5处,发现它本来就在索引5处&lt;/p&gt;  &lt;p&gt;全部排序完毕&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2011/11/23/2260312.html"&gt;返回主目录 [经典排序算法][集锦]&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.cnblogs.com/kkun/aggbug/2266559.html?type=1" width="1" height="1" alt=""/&gt;&lt;p&gt;&lt;a href="http://www.cnblogs.com/kkun/archive/2011/11/28/2266559.html" target="_blank"&gt;本文链接&lt;/a&gt;&lt;/p&gt;</content></entry></feed>
