<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-272429821527780388</id><updated>2026-03-20T00:11:08.503-07:00</updated><category term="Java"/><category term="Database"/><category term="IOS"/><category term="C#"/><category term="JS"/><category term="Adobe Flex"/><category term="MSSQL"/><category term="Design"/><category term="Hibernate"/><category term="Linux"/><category term="report"/><category term="ASP.NET"/><category term="System Design"/><category term="css"/><category term="oracle"/><title type='text'>Code-StandUp</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>127</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-7802392173214815855</id><published>2011-11-28T18:47:00.000-08:00</published><updated>2011-11-28T18:48:20.155-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS"/><title type='text'>IOS delegate你必須知道的事情</title><content type='html'>&lt;h3 class=&quot;post-title entry-title&quot; style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; position: relative; font: normal normal normal 22px/normal Georgia, Utopia, &#39;Palatino Linotype&#39;, Palatino, serif; color: rgb(213, 42, 51); text-align: -webkit-auto; background-color: rgb(254, 253, 250); &quot;&gt;ios delegate你必須知道的事情&lt;/h3&gt;&lt;div class=&quot;post-header&quot; style=&quot;line-height: 1.6; margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; color: rgb(51, 51, 51); font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; text-align: -webkit-auto; background-color: rgb(254, 253, 250); &quot;&gt;&lt;div class=&quot;post-header-line-1&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-3258977602601950133&quot; style=&quot;width: 699px; position: relative; line-height: 11px; color: rgb(51, 51, 51); font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; text-align: -webkit-auto; background-color: rgb(254, 253, 250); &quot;&gt;當你開始寫iOS程式不久，應該開始面對到很多的delegate，&lt;br /&gt;不管是用別人的library或是自己寫library，可能都逃不了delegate。&lt;br /&gt;為了怕有些人不知道什麼是delegate，在這邊簡單的介紹一下，&lt;br /&gt;delegate中文叫做委託，通常會用在class內部把一些事件處理&quot;委託&quot;給別人去完成。&lt;br /&gt;舉個例子，XML Parser可能他知道怎麼parse xml，但是parse到的東西要怎麼處理xml parser可能不知道。&lt;br /&gt;所以NSXMLParser就提供了一個NSXMLParserDelegate給client去實作，&lt;br /&gt;當parse到某個element的時候，就callback delegate所定義的message，&lt;br /&gt;讓他client自己去決定怎麼去處理這個element。&lt;br /&gt;好吧，我承認我解釋的很模糊，不過我這篇本來就不是要你搞懂什麼是delegate，&lt;br /&gt;而是針對使用或是設計delegate的時候，可能會要注意的事情。&lt;br /&gt;&lt;br /&gt;在我們的class中設計delegate的時候，我們通常會有幾個注意事項。&lt;br /&gt;假設我的class叫做MyClass，那我們可能會有定義一個MyClassDelegate這個protocol當作我的delegate protocol。&lt;br /&gt;而MyClass中我們可能是這樣寫。&lt;br /&gt;&lt;pre class=&quot;code&quot; style=&quot;border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(170, 177, 35); border-right-color: rgb(170, 177, 35); border-bottom-color: rgb(170, 177, 35); border-left-color: rgb(170, 177, 35); padding-top: 5px; padding-right: 20px; padding-bottom: 5px; padding-left: 5px; color: black; &quot;&gt;@protocol MyClassDelegate &lt;nsobject&gt; - (void) myClassOnSomeEvent:(MyClass*)myClass; @end  @interface MyClass {     id&lt;myclassdelegate&gt; _delegate; } @property (nonatomic, assign) delegate; @end &lt;/myclassdelegate&gt;&lt;/nsobject&gt;&lt;/pre&gt;上面的code我們注意到&lt;code style=&quot;font-size: 12px !important; background-color: rgb(248, 248, 255) !important; color: rgb(68, 68, 68) !important; padding-top: 0px !important; padding-right: 0.2em !important; padding-bottom: 0px !important; padding-left: 0.2em !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; border-top-color: rgb(222, 222, 222) !important; border-right-color: rgb(222, 222, 222) !important; border-bottom-color: rgb(222, 222, 222) !important; border-left-color: rgb(222, 222, 222) !important; &quot;&gt;delegate&lt;/code&gt;此property是定義為&lt;code style=&quot;font-size: 12px !important; background-color: rgb(248, 248, 255) !important; color: rgb(68, 68, 68) !important; padding-top: 0px !important; padding-right: 0.2em !important; padding-bottom: 0px !important; padding-left: 0.2em !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; border-top-color: rgb(222, 222, 222) !important; border-right-color: rgb(222, 222, 222) !important; border-bottom-color: rgb(222, 222, 222) !important; border-left-color: rgb(222, 222, 222) !important; &quot;&gt;@property (assign)&lt;/code&gt;。&lt;br /&gt;為什麼我們不用retain而要用assign呢?&lt;br /&gt;原因就是在於iOS的reference counting的環境中，我們必須解決circular count的問題。&lt;br /&gt;讓我們來寫寫我們平常都怎麼用delegate的，下面的code我想大家應該不陌生&lt;br /&gt;&lt;pre class=&quot;code&quot; style=&quot;border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(170, 177, 35); border-right-color: rgb(170, 177, 35); border-bottom-color: rgb(170, 177, 35); border-left-color: rgb(170, 177, 35); padding-top: 5px; padding-right: 20px; padding-bottom: 5px; padding-left: 5px; color: black; &quot;&gt;- (void)someAction {    myClass = [MyClass new];    myClass.delegate = self;    .... } &lt;/pre&gt;這邊很快的就出現circular reference了&lt;br /&gt;假設上面的code是寫在一個myViewController的物件當中，&lt;br /&gt;之後一旦myViewController的reference count變成1的時候，&lt;br /&gt;myViewController跟myClass這兩個兄弟兩只剩下互相retain，那就變成了孤島，也就因此造成了memory leak!!!&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuYJ0dL_fs4E7KERCEFrc6jSGl6CJCKt0OypMCwOheXGpKr-4ym9ie_HqfcytN4K83jF0nPS7cjomYn1pK8YDW-XIR1ZxNc1Y25dq5ReIOtu3fdwrajgN9r-rV9Nop7SsKAc1zmtbxHMY/s1600/delegate1.png&quot; style=&quot;text-decoration: none; color: rgb(213, 42, 51); &quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuYJ0dL_fs4E7KERCEFrc6jSGl6CJCKt0OypMCwOheXGpKr-4ym9ie_HqfcytN4K83jF0nPS7cjomYn1pK8YDW-XIR1ZxNc1Y25dq5ReIOtu3fdwrajgN9r-rV9Nop7SsKAc1zmtbxHMY/s320/delegate1.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5632104295644286354&quot; style=&quot;border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; border-color: initial; position: relative; padding-top: 8px; padding-right: 8px; padding-bottom: 8px; padding-left: 8px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); -webkit-box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 20px; box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 20px; border-top-left-radius: 5px 5px; border-top-right-radius: 5px 5px; border-bottom-right-radius: 5px 5px; border-bottom-left-radius: 5px 5px; cursor: pointer; width: 320px; height: 137px; background-position: initial initial; background-repeat: initial initial; &quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;也因為這樣，iOS官方文件才會要建議我們所以的delegate都要用assign property。&lt;br /&gt;也就是所謂&quot;weak reference&quot;的property，他的特色就是雖然會持有對方的reference，但是不會增加retain count。&lt;br /&gt;如此下來，當myViewController的retain count變成0，則會dealloc。&lt;br /&gt;同時在dealloc中，也一併把myClass release，則myClass也跟著被release。&lt;br /&gt;&lt;pre class=&quot;code&quot; style=&quot;border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(170, 177, 35); border-right-color: rgb(170, 177, 35); border-bottom-color: rgb(170, 177, 35); border-left-color: rgb(170, 177, 35); padding-top: 5px; padding-right: 20px; padding-bottom: 5px; padding-left: 5px; color: black; &quot;&gt;- (void)dealloc {    [myClass release];    [super dealloc]; } &lt;/pre&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjS2IZv7dd1Yw-q8f9QdKcoA13GjQ84tD9Dj2j2c1DxMVeWClnQQmbb44Puh8oQ7K-u9sxToAsW75O1sBrnavL6f7_azUBFFziqa6stMdMeO_qnr_KiftFyVO9NoTlbPHVK6JnEes93N6o/s1600/delegate2.png&quot; style=&quot;text-decoration: none; color: rgb(213, 42, 51); &quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjS2IZv7dd1Yw-q8f9QdKcoA13GjQ84tD9Dj2j2c1DxMVeWClnQQmbb44Puh8oQ7K-u9sxToAsW75O1sBrnavL6f7_azUBFFziqa6stMdMeO_qnr_KiftFyVO9NoTlbPHVK6JnEes93N6o/s320/delegate2.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5632104294537984130&quot; style=&quot;border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; border-color: initial; position: relative; padding-top: 8px; padding-right: 8px; padding-bottom: 8px; padding-left: 8px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); -webkit-box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 20px; box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 20px; border-top-left-radius: 5px 5px; border-top-right-radius: 5px 5px; border-bottom-right-radius: 5px 5px; border-bottom-left-radius: 5px 5px; cursor: pointer; width: 320px; height: 186px; background-position: initial initial; background-repeat: initial initial; &quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;事情就結束了嗎? 還沒有唷...&lt;br /&gt;這邊還有一個大家常常忘記的重點，那就是上面的dealloc這樣寫會有潛在危險。&lt;br /&gt;應該要改成這樣&lt;br /&gt;&lt;pre class=&quot;code&quot; style=&quot;border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(170, 177, 35); border-right-color: rgb(170, 177, 35); border-bottom-color: rgb(170, 177, 35); border-left-color: rgb(170, 177, 35); padding-top: 5px; padding-right: 20px; padding-bottom: 5px; padding-left: 5px; color: black; &quot;&gt;- (void)dealloc {    &lt;span &gt;myClass.delegate = nil;&lt;/span&gt;    [myClass release];    [super dealloc]; } &lt;/pre&gt;你可能會很納悶，myClass不是馬上就會被release了嗎? 幹嘛要先把他的delegate設成nil?&lt;br /&gt;那是因為我們假設myClass會馬上會被dealloc，但是現實狀況這個是不一定的，&lt;br /&gt;有可能裡面內部有建個NSURLConnection，或是正在做某件事情而讓其他物件也retain myClass。&lt;br /&gt;如果myClass沒有馬上dealloc，那他的&lt;code style=&quot;font-size: 12px !important; background-color: rgb(248, 248, 255) !important; color: rgb(68, 68, 68) !important; padding-top: 0px !important; padding-right: 0.2em !important; padding-bottom: 0px !important; padding-left: 0.2em !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; border-top-color: rgb(222, 222, 222) !important; border-right-color: rgb(222, 222, 222) !important; border-bottom-color: rgb(222, 222, 222) !important; border-left-color: rgb(222, 222, 222) !important; &quot;&gt;myClass.delegate&lt;/code&gt;不就正指向一個不合法的位置了嗎? (此種pointer稱作dangling pointer)&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlIYQXVMbJQBCZQtPNOAb48pwBUh8ovqI5rZTjgf_sW5Jflo09-jl0UM_3VL_UOYeIziADFL8Wb57LDJJgV_qZ8nN-9BzN5hVrqVyonBxCes2cPLfTUOrYJie96xKRu8Q7nneIV7AEV64/s1600/delegate3.png&quot; style=&quot;text-decoration: none; color: rgb(213, 42, 51); &quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlIYQXVMbJQBCZQtPNOAb48pwBUh8ovqI5rZTjgf_sW5Jflo09-jl0UM_3VL_UOYeIziADFL8Wb57LDJJgV_qZ8nN-9BzN5hVrqVyonBxCes2cPLfTUOrYJie96xKRu8Q7nneIV7AEV64/s320/delegate3.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5632104299513124754&quot; style=&quot;border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; border-color: initial; position: relative; padding-top: 8px; padding-right: 8px; padding-bottom: 8px; padding-left: 8px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); -webkit-box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 20px; box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 20px; border-top-left-radius: 5px 5px; border-top-right-radius: 5px 5px; border-bottom-right-radius: 5px 5px; border-bottom-left-radius: 5px 5px; cursor: pointer; width: 320px; height: 184px; background-position: initial initial; background-repeat: initial initial; &quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;解決方法是在MyViewController的dealloc中，在release myClass之前，&lt;br /&gt;要先把原本指向自己的delegate改設成nil，這樣才可以避免crash發生。&lt;br /&gt;在我之前寫的project，很大一部份的crash都是這樣造成的，因為這個問題通常不是每次都發生，&lt;br /&gt;但是發生的時候確很難在重新複製，所以不可不慎啊。&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRIEHUwCY0dQ1anmjduI51KUHM-EZ9vBlA_ARIQ1ImokF4LCUI6J1J0Q3Xto2e2ug5sTShBLm-uNNeqELzSH2-emyt_bWG1et7w79Qgoc0YzAvFUjw65IpnMnxI1IlbfLEKqXkcN34BMk/s1600/delegate4.png&quot; style=&quot;text-decoration: none; color: rgb(213, 42, 51); &quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRIEHUwCY0dQ1anmjduI51KUHM-EZ9vBlA_ARIQ1ImokF4LCUI6J1J0Q3Xto2e2ug5sTShBLm-uNNeqELzSH2-emyt_bWG1et7w79Qgoc0YzAvFUjw65IpnMnxI1IlbfLEKqXkcN34BMk/s320/delegate4.png&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5632104306871986450&quot; style=&quot;border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-width: initial; border-color: initial; position: relative; padding-top: 8px; padding-right: 8px; padding-bottom: 8px; padding-left: 8px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); -webkit-box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 20px; box-shadow: rgba(0, 0, 0, 0.199219) 0px 0px 20px; border-top-left-radius: 5px 5px; border-top-right-radius: 5px 5px; border-bottom-right-radius: 5px 5px; border-bottom-left-radius: 5px 5px; cursor: pointer; width: 320px; height: 182px; background-position: initial initial; background-repeat: initial initial; &quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;但是很興奮的是到了iOS5中的&lt;a href=&quot;http://popcornylu.blogspot.com/2011/06/arc-automatic-reference-counting.html&quot; style=&quot;text-decoration: none; color: rgb(213, 42, 51); &quot;&gt;Automatic Reference Counting&lt;/a&gt;這個問題可以有所改善。&lt;br /&gt;在ARC中提出了一個新的weak reference的概念來取代原本的assign，&lt;br /&gt;weak reference指到的物件若是已經因retain count歸零而dealloc了，則此weak reference也自動設成nil。&lt;br /&gt;而原本舊的這種assign的作法，在ARC中叫做__unsafe_unretained，這只是為了相容iOS4以下的版本。&lt;br /&gt;&lt;br /&gt;回顧重點:&lt;br /&gt;如果你是寫library給別人用的，記得把你的delegate設成assign property，這樣才不會造成circular reference&lt;br /&gt;當你是要始用別人的library，記得在你自己dealloc的時候，把delegate設成nil，以避免crash的事情發生。&lt;/div&gt;&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-3258977602601950133&quot; style=&quot;width: 699px; position: relative; line-height: 11px; color: rgb(51, 51, 51); font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; text-align: -webkit-auto; background-color: rgb(254, 253, 250); &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;post-body entry-content&quot; id=&quot;post-body-3258977602601950133&quot; style=&quot;width: 699px; position: relative; line-height: 11px; color: rgb(51, 51, 51); font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; text-align: -webkit-auto; background-color: rgb(254, 253, 250); &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;source: &lt;/span&gt;&lt;a href=&quot;http://webcache.googleusercontent.com/search?q=cache:dv0DZ9ilW3oJ:popcornylu.blogspot.com/2011/07/delegate.html+&amp;amp;cd=4&amp;amp;hl=zh-TW&amp;amp;ct=clnk&amp;amp;lr=lang_zh-CN%7Clang_zh-TW&quot; style=&quot;font-family: Georgia, serif; line-height: normal; text-align: left; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;http://webcache.googleusercontent.com/search?q=cache:dv0DZ9ilW3oJ:popcornylu.blogspot.com/2011/07/delegate.html+&amp;amp;cd=4&amp;amp;hl=zh-TW&amp;amp;ct=clnk&amp;amp;lr=lang_zh-CN%7Clang_zh-TW&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/7802392173214815855/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/7802392173214815855' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/7802392173214815855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/7802392173214815855'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/11/ios-delegate.html' title='IOS delegate你必須知道的事情'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuYJ0dL_fs4E7KERCEFrc6jSGl6CJCKt0OypMCwOheXGpKr-4ym9ie_HqfcytN4K83jF0nPS7cjomYn1pK8YDW-XIR1ZxNc1Y25dq5ReIOtu3fdwrajgN9r-rV9Nop7SsKAc1zmtbxHMY/s72-c/delegate1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-2207212485461231087</id><published>2011-11-07T02:53:00.000-08:00</published><updated>2011-11-07T02:54:28.992-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS"/><title type='text'>IOS UITableView 重用机制浅析</title><content type='html'>&lt;table style=&quot;line-height: 20px !important; table-layout: fixed; font-family: Arial; background-color: rgb(228, 227, 225); width: 940px; &quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; &quot;&gt;&lt;div id=&quot;blog_text&quot; class=&quot;cnt&quot; style=&quot;word-wrap: break-word; word-break: normal; visibility: visible !important; zoom: 1 !important; filter: none; color: rgb(15, 28, 56); letter-spacing: 1px; overflow-x: hidden; overflow-y: hidden; position: relative !important; &quot;&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;iphone重用机制是苹果为了实现大量数据显示而采用的一种节省内存的机制，但是在实际使用过程中，会有以下问题：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;1、使用addSubView在每项上添加视图的时候会有重叠的现象。例如，UITableView中的Cell ，如果在cell上添加视图，则在使用苹果的重用机制的时候，会重现重叠的现象。刚开始学习的时候，觉得这个重用不太合适，&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;原因：在数据不是很多的时候，个人觉得使用不使用重用机制都可以&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;，于是乎，干脆放弃使用这套机制。代码如下：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];&lt;br /&gt;    if (cell != nil) {&lt;br /&gt;        [cell release];&lt;br /&gt;    }&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;但是在数据多的时候，感觉使用重用机制会好对你的程序的内存使用和优化都有很重要的作用。&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt; 但是这样的话，如果想再cell上添加东西的话，重叠现象会很严重。偶然间，使用xib给cell添加视图，发现不会出现重叠的现象。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;具体步骤：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;（1）新建一个基于UITableViewCell的类A和一个空白的xib。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;（2）在A类中声明要添加的视图，例如IBOutlet UILabel *nameLabel,*timeLabel; ，注意：一要是使用&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;IBOutlet。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;（3）将xib中的view删除，拖一个 &lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;UITableViewCell，然后将这个&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;UITableViewCell的类改为基于A。再把相应的视图添在&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;UITableViewCell上，并且与A类内定义的变量进行连接。这样准备工作就完成了。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;（4）使用方法：&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;                 A* cell = (A*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];&lt;br /&gt;                 if (cell == nil) {&lt;br /&gt;                         NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@&quot;VideoCell&quot; owner:self options:nil];&lt;br /&gt;                         cell = [nib objectAtIndex:0];&lt;br /&gt;                 }&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;然后只需在下面改变cell相应视图的属性就可以了。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;补充：在使用地图MKMapView一会使用到重用机制，如果想要在MKPinAnnotationView添加视图的话，最好放弃那个重用机制，要不然效果会乱七八糟的～～&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;2、我相信很多人都会好奇这套重用机制怎么实现的？我也很好奇，一直没找到相关的文档。不过有些认为就是建一个队列或者池子，如果&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;UITableViewCell过多的话，它就会自动清除一些cell，然后如果比较少，它就会自动在这个队列或池子里面添加元素，这样避免了许多使用相同的Style 的Cell。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;PS：还是好好研究下C语言的内存管理吧，我觉得那个才是真真意义上的内存管理。OC内存管理还是比较简单的。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;strong&gt;&lt;span style=&quot;color: rgb(255, 0, 0); font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;更正：&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;今天查别的问题的时候偶尔看到一个老外写的UITableView的代码，发现了一种新的实现方式。实现方式如下：&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;strong&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;    1、cell的释放使用默认的释放：&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];&lt;br /&gt;    if (cell == nil) {&lt;br /&gt;        cell = [[[&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;UITableViewCell alloc&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;] init....] autorelease];&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;        &lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;UITextField&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt; *&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;field&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt; = ...;//初始化&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;        [cell addSubView:&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;field&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;];//添加&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;        [&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;field&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt; release];//释放&lt;/span&gt;       &lt;br /&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;    }&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;     &lt;strong&gt;2、通过遍历修改UILabel属性&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;&lt;strong&gt;  &lt;/strong&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;UITextField&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;*field = nil;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;   for(UIView *v in cell.contentView.subviews)&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;   {&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;  &lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;       if([v isMemberOfClass:[UILabel class]])&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;             &lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;field&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt; = (UITextField *)v;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;   }&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;   ......//修改&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;field&lt;/span&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;的属性&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;这种方法不敢说有多好，但是给我们提供了一种解决方案，看大家的喜好了｀｀｀ 例如不喜欢xib的，可以尝试下&lt;b&gt;.&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;line-height: normal; &quot;&gt;&lt;span style=&quot;font-size: 18px; font-family: &#39;Comic Sans MS&#39;; &quot;&gt;&lt;b&gt;source: &lt;/b&gt;&lt;/span&gt;&lt;a href=&quot;http://hi.baidu.com/%CB%E6%B7%E7_1989/blog/item/077c8a944ae7a69ca877a41d.html&quot; style=&quot;line-height: 20px; &quot;&gt;http://hi.baidu.com/%CB%E6%B7%E7_1989/blog/item/077c8a944ae7a69ca877a41d.html&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/2207212485461231087/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/2207212485461231087' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/2207212485461231087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/2207212485461231087'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/11/ios-uitableview.html' title='IOS UITableView 重用机制浅析'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-5168853775047390599</id><published>2011-11-07T02:00:00.001-08:00</published><updated>2011-11-07T02:00:42.734-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS"/><title type='text'>IOS内存管理</title><content type='html'>&lt;p style=&quot;margin-top: 20px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: &#39;Lucida Grande&#39;, Geneva, Arial, Verdana, sans-serif; font-size: 14px; line-height: 1.8; color: rgb(51, 51, 51); text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;&lt;strong style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; &quot;&gt;内存管理&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 20px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: &#39;Lucida Grande&#39;, Geneva, Arial, Verdana, sans-serif; font-size: 14px; line-height: 1.8; color: rgb(51, 51, 51); text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;    我一直惊叹iOS和Objective-C内存处理能力，例如iPad版本的iWork，Pages应用就是一个内存处理技术应用的鬼斧神工之作。想想256M内存的iPad，可以带来如此的华丽的界面同时获得如此流畅的用户体验，真是不简单。原因就是iOS一直提倡开发者在有限硬件资源内写出最优化的代码，使用CPU最少，占用内存最小。（以下代码适用于iOS SDK 4.1, 由于新SDK 4.2对内存使用有新改动，所以可能有不同。。。）&lt;/p&gt;&lt;ol style=&quot;margin-top: 30px; margin-right: 0px; margin-bottom: 30px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: &#39;Lucida Grande&#39;, Geneva, Arial, Verdana, sans-serif; color: rgb(51, 51, 51); line-height: 17px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); font-size: medium; &quot;&gt;&lt;li style=&quot;margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-size: 14px; &quot;&gt;尽量少的UIView层&lt;br /&gt;    通常我们喜欢把很多控件层（UILabel，UIButton，UIView等）一起放到一个大的UIView容器来显示我们的内容，这个方法一般是可以的，但是如果要经常重新刷新内容的大区域界面，多数发生在iPad的应用中，这个方法会带来过多的内存使用和动画的延迟（比较卡），例如，scrollview的动画比较卡，又或者，经常收到内存警告。其中一个重要原因是每个控件，特别是透明底的，会多次重新绘制（drawRect）过多。其解决办法是，尽量将几个控件合并到一个层上来显示，这样系统会减少系统调用drawRect，从而带来性能上的提升。&lt;br /&gt;    很简单的一个例子，就是iNotes提供手写功能，用户可以在iPad屏幕上写出不同的笔画，开始的设计是，用户每写一划，iNotes就会生成一个新的透明底UIView来保持这个笔画，用户写了10笔，系统就生产了10个UIView，每个view的大小都是整个屏幕的，以便用户的undo操作。这个方案带来严重的内存问题，因为系统将每个层都保持一个bitmap图，一个像素需要4bit来算，一个层的大小就是 4x1024x768 ~ 3M, 10个层就是 10x3M = 30M，很明显，iPad很快爆出内存警告。&lt;br /&gt;    这个例子最后的方案是，所有笔画都画在同一个层，iNotes可以保存笔画的点进行undo操作。这样的方案就是无论用户画多少笔画，界面重画需要的资源都是一样的。&lt;/li&gt;&lt;li style=&quot;margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-size: 14px; &quot;&gt;显示最佳尺寸的图片&lt;br /&gt;    很多程序员比较懒，网络上拿下来的图片，直接就用UIImageView将其显示给用户，这样的后果就是，程序需要一直保存着大尺寸的图片到内存。解决办法应该是先将图片缩小到需要显示的尺寸，释放大尺寸图片的内存，然后再显示到界面给用户。&lt;/li&gt;&lt;li style=&quot;margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-size: 14px; &quot;&gt;尽量使用图片pattern，而不是一张大的图片&lt;br /&gt;    例如，很多界面设计者喜欢在界面上放一个大底图，但这个底图是老是占用着内存的，最佳方案是，设计出一个小的pattern图，然后用这个方案显示成底图。&lt;br /&gt;   &lt;span style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(0, 128, 128); &quot;&gt; UIImage *smallImage = [[UIImage alloc] initWithContentsOfFile:path]; &lt;br /&gt;    backgroundView.backgroundColor = [UIColor colorWithPatternImage:smallImage];  &lt;br /&gt;    [smallImage release]; &lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-size: 14px; &quot;&gt;使用完资源后，立即释放&lt;br /&gt;    一般objective-c的习惯是，用完的资源要立即释放，因为明白什么时候用完某个资源的是程序员你自己。例如，我们要读较大的图片，把它缩小后，显示到界面去。当大图片使用完成后，应该立即释放。代码如下：&lt;br /&gt;    &lt;span style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(0, 128, 128); &quot;&gt;UIImage *fullscreenImage = [[UIImage alloc] initWithContentOfFile:path];  &lt;br /&gt;    UIImage *smallImage = [self resizeImage:fullscreenImage]; &lt;br /&gt;    [fullscreenImage release];        &lt;br /&gt;    imageView.image = smallImage;  &lt;/span&gt;&lt;br /&gt;      &lt;br /&gt;    ...... &lt;/li&gt;&lt;li style=&quot;margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; line-height: 20px; font-size: 14px; &quot;&gt;循环中大量生成的自动释放autorelease对象，可以考虑使用autorelease pool封装。代码范例：&lt;br /&gt;&lt;span style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(0, 128, 128); &quot;&gt;    for(UIView *subview in bigView.subviews) {  &lt;br /&gt;        // 使用autorelease pool自动释放对象池  &lt;br /&gt;        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];  &lt;br /&gt;      &lt;br /&gt;        UIImageView *imageView = (UIImageView *)subview;  &lt;br /&gt;          &lt;br /&gt;        // subview处理代码  &lt;br /&gt;        .......  &lt;br /&gt;      &lt;br /&gt;        // 销毁自动释放对象  &lt;br /&gt;        [pool  drain];  &lt;br /&gt;    }  &lt;/span&gt;&lt;br /&gt;自动释放对象池把每个循环内生成的临时对象使用完后立即释放&lt;/li&gt;&lt;/ol&gt;&lt;p style=&quot;margin-top: 20px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: &#39;Lucida Grande&#39;, Geneva, Arial, Verdana, sans-serif; font-size: 14px; line-height: 1.8; color: rgb(51, 51, 51); text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;    以上的意见是本人多年来编写iPad/iPhone程序的经验，另外iOS4.0的multi-tasking特性发布后，程序可以被调入后台运行，苹果 工程师的意见是，进入后台运行时，你的应用应该释放掉能释放的对象，尽量保持在16M左右，这样别的程序运行时才不容易把你的应用挤掉。&lt;/p&gt;&lt;p style=&quot;margin-top: 20px; margin-right: 0px; margin-bottom: 20px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: &#39;Lucida Grande&#39;, Geneva, Arial, Verdana, sans-serif; font-size: 14px; line-height: 1.8; color: rgb(51, 51, 51); text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;source: &lt;a href=&quot;http://www.cocoachina.com/iphonedev/sdk/2011/0621/2962.html&quot; style=&quot;font-family: Georgia, serif; font-size: 16px; line-height: normal; text-align: left; &quot;&gt;http://www.cocoachina.com/iphonedev/sdk/2011/0621/2962.html&lt;/a&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/5168853775047390599/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/5168853775047390599' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5168853775047390599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5168853775047390599'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/11/ios.html' title='IOS内存管理'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-7557312686404873600</id><published>2011-11-06T23:11:00.000-08:00</published><updated>2011-11-06T23:12:42.004-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS"/><title type='text'>iPhone/Mac Objective-C內存管理教程和原理剖析</title><content type='html'>&lt;div align=&quot;left&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; background-color: rgb(255, 255, 255); &quot;&gt;前言&lt;/div&gt;&lt;div align=&quot;left&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; background-color: rgb(255, 255, 255); &quot;&gt;初学objectice-C的朋友都有一个困惑，总觉得对objective-C的内存管理机制琢磨不透，程序经常内存泄漏或莫名其妙的崩溃。我在这里总结了自己对objective-C内存管理机制的研究成果和经验，写了这么一个由浅入深的教程。希望对大家有所帮助，也欢迎大家一起探讨。&lt;/div&gt;&lt;div align=&quot;left&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; background-color: rgb(255, 255, 255); &quot;&gt; &lt;/div&gt;&lt;div align=&quot;left&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; background-color: rgb(255, 255, 255); &quot;&gt;此文涉及的内存管理是针对于继承于NSObject的Class。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;一 基本原理&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;Objective-C的内存管理机制与.Net/Java那种全自动的垃圾回收机制是不同的，它本质上还是C语言中的手动管理方式，只不过稍微加了一些自动方法。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21.25pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: -21.25pt; &quot;&gt;1&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 7pt/normal &#39;Times New Roman&#39;; &quot;&gt;           &lt;/span&gt;Objective-C的对象生成于堆之上，生成之后，需要一个指针来指向它。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;ClassA *obj1 = [[ClassA alloc] init];&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt; &lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21.25pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: -21.25pt; &quot;&gt;2&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 7pt/normal &#39;Times New Roman&#39;; &quot;&gt;           &lt;/span&gt;Objective-C的对象在使用完成之后不会自动销毁，需要执行dealloc来释放空间（销毁），否则内存泄露。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj1 dealloc];&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;         这带来了一个问题。下面代码中obj2是否需要调用dealloc？&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;ClassA *obj1 = [[ClassA alloc] init];&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;ClassA *obj2 = obj1;&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj1 hello]; //输出hello&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj1 dealloc];&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj2 hello]; //能够执行这一行和下一行吗？&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj2 dealloc];&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;         不能，因为obj1和obj2只是指针，它们指向同一个对象，[obj1 dealloc]已经销毁这个对象了，不能再调用[obj2 hello]和[obj2 dealloc]。obj2实际上是个无效指针。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;         如何避免无效指针？请看下一条。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt; &lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21.25pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: -21.25pt; &quot;&gt;3&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 7pt/normal &#39;Times New Roman&#39;; &quot;&gt;           &lt;/span&gt;Objective-C采用了引用计数(ref count或者retain count)。对象的内部保存一个数字，表示被引用的次数。例如，某个对象被两个指针所指向（引用）那么它的retain count为2。需要销毁对象的时候，不直接调用dealloc，而是调用release。release会让retain count减1，只有retain count等于0，系统才会调用dealloc真正销毁这个对象。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;ClassA *obj1 = [[ClassA alloc] init]; //对象生成时，retain count = 1&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj1 release]; //release使retain count减1，retain count = 0，dealloc自动被调用,对象被销毁&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;我们回头看看刚刚那个无效指针的问题，把dealloc改成release解决了吗？&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;ClassA *obj1 = [[ClassA alloc] init]; //retain count = 1&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;ClassA *obj2 = obj1; //retain count = 1&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj1 hello]; //输出hello&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj1 release]; //retain count = 0，对象被销毁&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj2 hello];&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: 21pt; &quot;&gt;[obj2 release];&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;         [obj1 release]之后，obj2依然是个无效指针。问题依然没有解决。解决方法见下一条。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt; &lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 21.25pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); text-indent: -21.25pt; &quot;&gt;4&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 7pt/normal &#39;Times New Roman&#39;; &quot;&gt;           &lt;/span&gt;Objective-C指针赋值时，retain count不会自动增加，需要手动retain。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;ClassA *obj1 = [[ClassA alloc] init]; //retain count = 1&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;ClassA *obj2 = obj1; //retain count = 1&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;&lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: red; &quot;&gt;[obj2 retain]; //retain count = 2&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;[obj1 hello]; //输出hello&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;[obj1 release]; //retain count = 2 – 1 = 1&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;[obj2 hello]; //输出hello&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;[obj2 release]; //retain count = 0，对象被销毁&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;问题解决！注意，如果没有调用[obj2 release]，这个对象的retain count始终为1，不会被销毁，内存泄露。(1-4可以参考附件中的示例程序memman-no-pool.m)&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;这样的确不会内存泄露，但似乎有点麻烦，有没有简单点的方法？见下一条。&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 42pt; color: rgb(51, 51, 51); font-family: Verdana, Arial, Tahoma; font-size: 14px; line-height: 25px; text-align: -webkit-auto; background-color: rgb(255, 255, 255); &quot;&gt;source: &lt;a href=&quot;http://www.aiw3.com/iphone/0521988.html&quot;&gt;http://www.aiw3.com/iphone/0521988.html&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/7557312686404873600/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/7557312686404873600' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/7557312686404873600'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/7557312686404873600'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/11/iphonemac-objective-c.html' title='iPhone/Mac Objective-C內存管理教程和原理剖析'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-5416305462300060631</id><published>2011-10-26T03:24:00.000-07:00</published><updated>2011-10-26T03:25:28.425-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS"/><title type='text'>Xcode 4.2 中的Automatic Reference Counting  (ARC)</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: rgb(248, 236, 216); &quot;&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Automatic Reference Counting (ARC),&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;自动引用计数，是开发&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Cocoa&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;程序时的一个编译级别的特性，用于自动内存管理。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;在&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;XCode 4.2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;中，使用模板新建一个工程，该工程将使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;特性。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;如果你的&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;iOS SDK&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;是&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;iOS5 seed release 2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;，需要做如下修改，才能避免编译时的错误：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;●&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;在&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;System/Library/Frameworks/CoreFoundation.framework/Headers/CFBase.h&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;中&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;,&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;将&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;CFTypeRef CFMakeCollectable(CFTypeRef cf) CF_AUTOMATED_REFCOUNT_UNAVAILABLE;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;修改成&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;CFTypeRef CFMakeCollectable(CFTypeRef cf);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;●&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;在&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;System/Library/Frameworks/Foundation.framework/Headers/NSObject.h&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;中&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;将&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;return (__bridge_retain CFTypeRef)X;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;修改成：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;return (__bridge_retained CFTypeRef)X;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;使用&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;将让你远离&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;烦人且容易遗漏的&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;retain&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;，&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;release&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;和&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;autorelease&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;等操作。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;的工作原理是，在你编译程序时，将内存操作的代码（&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;retain&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;，&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;release&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;或&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;autorelease&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;）自动添加到需要的位置。即底层上使用和&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Manual Reference Counting&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;（手工引用计数）一样的内存管理机制，但由于&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;XCode&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;自动帮你在编译时添加内存操作的代码，从而简化了编程的工作。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;启用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;，编译选项中需加上&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;-fobjc-arc&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;，不过这个由&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;XCode&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;在创建工程模板时帮你完成。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;4.2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;以前版本的&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;XCode&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;都不支持&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;对操作系统也有要求：&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Mac OS X v10.6&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;或&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;v10.7 (64-bit applications)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;，&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;iOS4&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;或&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;iOS5&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;。注意：其中&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Mac OS X v10.6&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;和&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;iOS4&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;不支持&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;weak references(&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;弱引用，后面会说明什么是&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;weak references)&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Xcode 4.2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;提供了一个名为“&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Convert to Objective-C Automatic Reference Counting”&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;的工具，在&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Edit-&amp;gt;Convert menu&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;下，可以帮你自动将使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Manual Reference Counting&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;的老代码转换成使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;的新代码（例如去掉对&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;retain&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;和&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;release&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;的调用）。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;一个使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;的代码例子：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@interface Person : NSObject&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@property (nonatomic, strong) NSString *firstName;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@property (nonatomic, strong) NSString *lastName;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@property (nonatomic, strong) NSNumber *yearOfBirth;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@property (nonatomic, strong) Person *spouse;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@implementation Person&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@synthesize firstName, lastName, yearOfBirth, spouse; @end&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;注意：不再需要重载&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;dealloc&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;函数&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;因为没有&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;release&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;操作。（&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;strong&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;的语义后面会介绍。&lt;/span&gt;）&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;例子&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;2&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;(void)contrived {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;Person *aPerson = [[Person alloc] init];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;[aPerson setFirstName:@&quot;William&quot;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;[aPerson setLastName:@&quot;Dudney&quot;];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;[aPerson:setYearOfBirth:[[NSNumber alloc] initWithInteger:2011]];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;NSLog(@&quot;aPerson: %@&quot;, aPerson);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;注意：没有了&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;release&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;操作。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;例子&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;(void)takeLastNameFrom:(Person *)person {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;NSString *oldLastname = [self lastName];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;[self setLastName:[person lastName]];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;NSLog(@&quot;Lastname changed from %@ to %@&quot;, oldLastname, [self lastName]);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;注意：&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;会保证&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;oldLastname&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;引用的对象在&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;NSLog&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;执行结束之前，不会被释放掉。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;的一些规则：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;不能直接调用&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;dealloc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;方法，不能&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;重载或直接调用&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;retain&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;release&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;retainCount&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;或&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;autorelease&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;等方法。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;但可以通过&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;@selector(retain)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;@selector(release)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;这样的形式调用。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;用户自定义的&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;dealloc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;方法，不能调用&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;[super dealloc]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;，编译器会自动帮你添加这个代码。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;对&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Core Foundation-style&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;的对象，仍可以使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;CFRetain, CFRelease&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;等方法。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;不能使用&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;NSAllocateObject&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;或&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;NSDeallocateObject&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;去创建对象，请使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;alloc&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;方法。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;在&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;c&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;语言中的结构体中，不能再使用对象指针。请放弃&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;结构体，使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;Objective-C&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;的类。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;id&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;和&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;void*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;之间没有隐式的类型转换，请使用显式类型转换。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;不能使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;NSAutoreleasePool&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;，&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;ARC&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;提供了&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;@autoreleasepool&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;语句块。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;例如：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@autoreleasepool {&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;// Code, such as a loop that creates a large number of temporary objects.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;不能使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;NSZone&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;方法和变量的命名不能以“&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;new”&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;开头。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;关于对象的生命周期：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;weak&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;引用&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;：设置成&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;weak&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;的属性，不会影响对象的生命周期，如果引用的对象已经被释放，引用会指向&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;nil&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;strong&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;引用：设置成&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;strong&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;的属性，会影响对象的生命周期。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;例如：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@property(strong) MyClass *myObject;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;和&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@property(retain) MyClass *myObject;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;是等效的。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;又例如：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@property(weak) MyClass *myObject;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;和&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;@property(assign) MyClass *myObject;&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;在多数情况下等效，但当&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;instance&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;被释放时，设置为&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;weak&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;的引用会指向&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;nil&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;可用的限定词：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;__strong&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;， 默认的&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;__weak&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;__unsafe_unretained&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;， 和&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;weak&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;的区别是当对象被释放时，引用不指向&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;nil&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;__autoreleasing&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;，当方法的参数是&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 18px; font-size: 9pt; &quot;&gt;id*&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;，且希望方法返回时对象被&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;autoreleased&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;，可以添加&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;__autoreleasing&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;限定词。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;使用&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;__weak&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;时要特别小心，例如&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;NSString __weak *string = [[NSString alloc] initWithFormat:@&quot;First Name: %@&quot;, [self firstName]];&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;NSLog(@&quot;string: %@&quot;, string); //&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;此时&lt;/span&gt;&lt;/span&gt; &lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;string&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;为空，因为&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;weak&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;类型不影响对象的生命周期，对象刚创建就释放了。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;其他特性：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;ul style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;li style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 30px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: disc; list-style-position: initial; list-style-image: initial; &quot;&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;使用&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;strong, weak, autoreleasing&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;限定的变量会被隐式初始化为&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;nil&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;例如：&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;- (void)myMethod { NSString *name;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p align=&quot;left&quot; style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;NSLog(@&quot;name: %@&quot;, name); //&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;会输出&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(70, 70, 70); margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; line-height: 19px; font-family: Helvetica, sans-serif; font-size: small; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 20px; &quot;&gt;&lt;span style=&quot;word-wrap: normal; word-break: normal; line-height: 15px; font-size: 8pt; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0cm; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; list-style-type: none; list-style-position: initial; list-style-image: initial; word-wrap: normal; word-break: normal; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 12px; line-height: 15px;&quot;&gt;source: &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://blog.sina.com.cn/s/blog_4c4c79950100t3uy.html&quot;&gt;http://blog.sina.com.cn/s/blog_4c4c79950100t3uy.html&lt;/a&gt;&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/5416305462300060631/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/5416305462300060631' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5416305462300060631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5416305462300060631'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/10/xcode-42-automatic-reference-counting.html' title='Xcode 4.2 中的Automatic Reference Counting  (ARC)'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-5466642847049907342</id><published>2011-10-26T02:50:00.000-07:00</published><updated>2011-10-26T02:51:23.954-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS"/><title type='text'>Error Handling Best Practice in IOS Dev</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); &quot;&gt;&lt;h1 id=&quot;pageTitle&quot; style=&quot;margin-top: 0px; margin-bottom: 1.15em; font: normal normal normal 215%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; color: rgb(0, 0, 0); padding-top: 24px; &quot;&gt;Exception Handling&lt;/h1&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_80&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;The Objective-C language has an exception-handling syntax similar to that of Java and C++. By using this syntax with the &lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_81&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_82&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;NSException&lt;/code&gt;, &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;NSError&lt;/code&gt;, or custom classes, you can add robust error-handling to your programs. This chapter provides a summary of exception syntax and handling; for more details, see &lt;em style=&quot;font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px; font-style: italic; &quot;&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/DOCUMENTATION/Cocoa/Conceptual/Exceptions/Exceptions.html#//apple_ref/doc/uid/10000012i&quot; target=&quot;_self&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;Exception Programming Topics&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;section&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-SW2&quot; title=&quot;Enabling Exception-Handling&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;h2 class=&quot;jump&quot; style=&quot;margin-top: 1.75em; font-size: 24px; color: rgb(60, 76, 108); padding-bottom: 2px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(131, 145, 168); &quot;&gt;Enabling Exception-Handling&lt;/h2&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;Using GNU Compiler Collection (GCC) version 3.3 and later, Objective-C provides language-level support for exception handling. To turn on support for these features&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_83&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_84&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;, use the &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;-fobjc-exceptions&lt;/code&gt; switch of the GNU Compiler Collection (GCC) version 3.3 and later. (Note that this switch renders the application runnable only in Mac OS X v10.3 and later&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_85&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_86&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt; because runtime support for exception handling and synchronization is not present in earlier versions of the software.)&lt;/p&gt;&lt;/section&gt;&lt;section&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-SW3&quot; title=&quot;Exception Handling&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;h2 class=&quot;jump&quot; style=&quot;margin-top: 1.75em; font-size: 24px; color: rgb(60, 76, 108); padding-bottom: 2px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(131, 145, 168); &quot;&gt;Exception Handling&lt;/h2&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;An exception is a special condition that interrupts the normal flow of program execution. There are a variety of reasons why an exception may be generated (exceptions are typically said to be&lt;em style=&quot;font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px; font-style: italic; &quot;&gt;raised&lt;/em&gt; or &lt;em style=&quot;font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px; font-style: italic; &quot;&gt;thrown&lt;/em&gt;), by hardware as well as software. Examples include arithmetical errors such as division by zero, underflow or overflow, calling undefined instructions (such as attempting to invoke an unimplemented method), and attempting to access a collection element out of bounds.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;Objective-C exception support involves four compiler directives: &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@try&lt;/code&gt;, &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@catch&lt;/code&gt;, &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@throw&lt;/code&gt;, and &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@finally&lt;/code&gt;:&lt;/p&gt;&lt;ul class=&quot;ul&quot; style=&quot;list-style-type: disc; list-style-position: outside; list-style-image: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0.833em; margin-left: 1.35em; padding-top: 0px; padding-right: 0px; padding-bottom: 0.5em; padding-left: 0px; &quot;&gt;&lt;li class=&quot;li&quot; style=&quot;margin-top: 0.583em; &quot;&gt;&lt;p style=&quot;margin-top: 0.667em; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; display: inline; &quot;&gt;Code that can potentially throw an exception is enclosed in a &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@try{}&lt;/code&gt; block.&lt;/p&gt;&lt;/li&gt;&lt;li class=&quot;li&quot; style=&quot;margin-top: 0.583em; &quot;&gt;&lt;p style=&quot;margin-top: 0.667em; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; display: inline; &quot;&gt;A &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@catch{}&lt;/code&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_87&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt; block contains exception-handling logic for exceptions thrown in a &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@try{}&lt;/code&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_88&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt; block. You can have multiple &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@catch{}&lt;/code&gt; blocks to catch different types of exception. (For a code example, see &lt;span class=&quot;content_text&quot; style=&quot;margin-top: 0px; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; margin-bottom: 0.833em; padding-bottom: 0.833em; vertical-align: top; &quot;&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/DOCUMENTATION/Cocoa/Conceptual/ObjectiveC/Chapters/ocExceptionHandling.html#//apple_ref/doc/uid/TP30001163-CH13-171873&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;“Catching Different Types of Exception.”&lt;/a&gt;&lt;/span&gt;)&lt;/p&gt;&lt;/li&gt;&lt;li class=&quot;li&quot; style=&quot;margin-top: 0.583em; &quot;&gt;&lt;p style=&quot;margin-top: 0.667em; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; display: inline; &quot;&gt;You use the &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@throw&lt;/code&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_89&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt; directive to throw an exception, which is essentially an Objective-C object. You typically use an &lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_90&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_91&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;NSException&lt;/code&gt; object, but you are not required to.&lt;/p&gt;&lt;/li&gt;&lt;li class=&quot;li&quot; style=&quot;margin-top: 0.583em; &quot;&gt;&lt;p style=&quot;margin-top: 0.667em; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; display: inline; &quot;&gt;A &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@finally{}&lt;/code&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_92&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt; block contains code that must be executed whether an exception is thrown or not.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;This example depicts a simple exception-handling algorithm:&lt;/p&gt;&lt;div class=&quot;codesample clear&quot; style=&quot;clear: both; font-size: 12px; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; &quot;&gt;&lt;table style=&quot;width: 1110px; background-color: rgb(241, 245, 249); border-collapse: collapse; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(199, 207, 213); border-right-color: rgb(199, 207, 213); border-bottom-color: rgb(199, 207, 213); border-left-color: rgb(199, 207, 213); padding-bottom: 4px; &quot;&gt;&lt;tbody&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;Cup *cup = [[Cup alloc] init];&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt; &lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;@try {&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    [cup fill];&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;}&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;@catch (NSException *exception) {&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    NSLog(@&quot;main: Caught %@: %@&quot;, [exception name], [exception reason]);&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;}&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;@finally {&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    [cup release];&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;}&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/section&gt;&lt;section&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-171873&quot; title=&quot;Catching Different Types of Exception&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-TPXREF169&quot; title=&quot;Catching Different Types of Exception&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;h2 class=&quot;jump&quot; style=&quot;margin-top: 1.75em; font-size: 24px; color: rgb(60, 76, 108); padding-bottom: 2px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(131, 145, 168); &quot;&gt;Catching Different Types of Exception&lt;/h2&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;To catch an exception thrown in a &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@try{}&lt;/code&gt; block, use one or more &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@catch{}&lt;/code&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_93&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_94&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;blocks following the &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@try{}&lt;/code&gt; block. The &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@catch{}&lt;/code&gt; blocks should be ordered from most-specific to least-specific. That way you can tailor the processing of exceptions as groups, as shown in &lt;span class=&quot;content_text&quot; style=&quot;margin-top: 0px; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; margin-bottom: 0.833em; padding-bottom: 0.833em; vertical-align: top; &quot;&gt;Listing 10-1&lt;/span&gt;.&lt;/p&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-171908&quot; title=&quot;Listing 10-1An exception handler&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-BCICHFFA&quot; title=&quot;Listing 10-1An exception handler&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;p class=&quot;codesample clear&quot; style=&quot;margin-top: 1.667em; margin-bottom: -0.85em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; clear: both; &quot;&gt;&lt;strong class=&quot;caption_number&quot; style=&quot;font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px; font-weight: bold; &quot;&gt;Listing 10-1&lt;/strong&gt;  An exception handler&lt;/p&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_95&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;div class=&quot;codesample clear&quot; style=&quot;clear: both; font-size: 12px; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; &quot;&gt;&lt;table style=&quot;width: 1110px; background-color: rgb(241, 245, 249); border-collapse: collapse; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(199, 207, 213); border-right-color: rgb(199, 207, 213); border-bottom-color: rgb(199, 207, 213); border-left-color: rgb(199, 207, 213); padding-bottom: 4px; &quot;&gt;&lt;tbody&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;@try {&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    ...&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;}&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;@catch (CustomException *ce) {   // 1&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    ...&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;}&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;@catch (NSException *ne) {       // 2&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    // Perform processing necessary at this level.&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    ...&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt; &lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;}&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;@catch (id ue) {&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    ...&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;}&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;@finally {                       // 3&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    // Perform processing necessary whether an exception occurred or not.&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;    ...&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;}&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;The following list describes the numbered code lines:&lt;/p&gt;&lt;ol class=&quot;ol&quot; style=&quot;list-style-type: decimal; list-style-position: outside; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 2.5em; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0.5em; &quot;&gt;&lt;li class=&quot;li&quot; style=&quot;margin-top: 0.583em; &quot;&gt;&lt;p style=&quot;margin-top: 0.667em; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; display: inline; &quot;&gt;Catches the most specific exception type.&lt;/p&gt;&lt;/li&gt;&lt;li class=&quot;li&quot; style=&quot;margin-top: 0.583em; &quot;&gt;&lt;p style=&quot;margin-top: 0.667em; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; display: inline; &quot;&gt;Catches a more general exception type.&lt;/p&gt;&lt;/li&gt;&lt;li class=&quot;li&quot; style=&quot;margin-top: 0.583em; &quot;&gt;&lt;p style=&quot;margin-top: 0.667em; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; display: inline; &quot;&gt;Performs any clean-up processing&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_96&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_97&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt; that must always be performed, whether exceptions were thrown or not.&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_98&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/section&gt;&lt;section&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-171819&quot; title=&quot;Throwing Exceptions&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-TPXREF168&quot; title=&quot;Throwing Exceptions&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;h2 class=&quot;jump&quot; style=&quot;margin-top: 1.75em; font-size: 24px; color: rgb(60, 76, 108); padding-bottom: 2px; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(131, 145, 168); &quot;&gt;Throwing Exceptions&lt;/h2&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_99&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_100&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;To throw an exception, you must instantiate an object with the appropriate information, such as the exception name and the reason it was thrown.&lt;/p&gt;&lt;div class=&quot;codesample clear&quot; style=&quot;clear: both; font-size: 12px; margin-top: 1.5em; margin-right: 0px; margin-bottom: 1.5em; margin-left: 0px; &quot;&gt;&lt;table style=&quot;width: 1110px; background-color: rgb(241, 245, 249); border-collapse: collapse; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(199, 207, 213); border-right-color: rgb(199, 207, 213); border-bottom-color: rgb(199, 207, 213); border-left-color: rgb(199, 207, 213); padding-bottom: 4px; &quot;&gt;&lt;tbody&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;NSException *exception = [NSException exceptionWithName: @&quot;HotTeaException&quot;&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;                                                 reason: @&quot;The tea is too hot&quot;&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;                                               userInfo: nil];&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr style=&quot;border-bottom-width: 0px; border-bottom-style: solid; border-bottom-color: rgb(255, 255, 255); &quot;&gt;&lt;td scope=&quot;row&quot; style=&quot;padding-top: 0.5em; padding-right: 0.5em; padding-bottom: 0.5em; padding-left: 0.5em; &quot;&gt;&lt;pre style=&quot;margin-top: -0.083em; margin-bottom: 0px; font-size: 12px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); margin-right: 0.333em; margin-left: 0.5em; line-height: 13px; white-space: pre-wrap; &quot;&gt;@throw exception;&lt;span style=&quot;margin-right: 0.667em; float: right; &quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;importantbox clear&quot; style=&quot;clear: both; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(80, 136, 197); border-right-color: rgb(80, 136, 197); border-bottom-color: rgb(80, 136, 197); border-left-color: rgb(80, 136, 197); background-color: rgb(240, 243, 247); margin-top: 1.667em; margin-right: 0px; margin-bottom: 1.75em; margin-left: 0px; padding-top: 0px; padding-right: 0.667em; padding-bottom: 0.083em; padding-left: 0.75em; &quot;&gt;&lt;aside&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_2&quot; title=&quot;Important:&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;p style=&quot;margin-top: 0.583em; margin-bottom: 0px; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;&lt;strong style=&quot;font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px; font-weight: bold; &quot;&gt;Important:&lt;/strong&gt; In many environments, use of exceptions is fairly commonplace. For example, you might throw an exception to signal that a routine could not execute normally—such as when a file is missing or data could not be parsed correctly. Exceptions are resource-intensive in Objective-C. You should not use exceptions for general flow-control, or simply to signify errors. Instead you should use the return value of a method or function to indicate that an error has occurred, and provide information about the problem in an error object. For more information, see&lt;em style=&quot;font-family: &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; font-size: 13px; font-style: italic; &quot;&gt;&lt;a href=&quot;http://developer.apple.com/library/ios/DOCUMENTATION/Cocoa/Conceptual/ErrorHandlingCocoa/ErrorHandling/ErrorHandling.html#//apple_ref/doc/uid/TP40001806&quot; target=&quot;_self&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;Error Handling Programming Guide&lt;/a&gt;&lt;/em&gt;.&lt;/p&gt;&lt;p style=&quot;margin-top: 0.583em; margin-bottom: 0px; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;&lt;/p&gt;&lt;/aside&gt;&lt;/div&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;Inside a &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@catch{}&lt;/code&gt; block, you can rethrow the caught exception using the &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;@throw&lt;/code&gt; directive without providing an argument. Leaving out the argument in this case can help make your code more readable.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;You are not limited to throwing &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;NSException&lt;/code&gt; objects. You can throw any Objective-C object as an exception object. The &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;NSException&lt;/code&gt; class provides methods that help in exception processing, but you can implement your own if you so desire. You can also subclass &lt;code style=&quot;font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); &quot;&gt;NSException&lt;/code&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_101&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt;&lt;a name=&quot;//apple_ref/doc/uid/TP30001163-CH13-DontLinkElementID_102&quot; style=&quot;color: rgb(51, 102, 204); text-decoration: none; &quot;&gt;&lt;/a&gt; to implement specialized types of exceptions, such as file-system exceptions or communications exceptions.&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0.833em; font: normal normal normal 100%/normal &#39;Lucida Grande&#39;, Geneva, Helvetica, Arial, sans-serif; &quot;&gt;source: &lt;a href=&quot;http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Conceptual/ObjectiveC/Chapters/ocExceptionHandling.html#//apple_ref/doc/uid/TP30001163-CH13-SW1&quot;&gt;link&lt;/a&gt;&lt;/p&gt;&lt;/section&gt;&lt;div id=&quot;pageNavigationLinks_bottom&quot; class=&quot;pageNavigationLinks&quot; style=&quot;margin-top: 0.75em; margin-bottom: 0px; float: right; &quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;pageNavigationLinks_bottom&quot; class=&quot;pageNavigationLinks&quot; style=&quot;margin-top: 0.75em; margin-bottom: 0px; float: right; &quot;&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/5466642847049907342/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/5466642847049907342' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5466642847049907342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5466642847049907342'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/10/error-handling-best-practice-in-ios-dev.html' title='Error Handling Best Practice in IOS Dev'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-49860479958785995</id><published>2011-10-19T19:57:00.000-07:00</published><updated>2011-10-19T19:59:17.996-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><category scheme="http://www.blogger.com/atom/ns#" term="oracle"/><title type='text'>Oracle Hint</title><content type='html'>在SQL中增加/*ordered */&lt;br /&gt;會使查詢效能顯著提升&lt;br /&gt;原來這叫做Oracle Hint&lt;br /&gt;&lt;br /&gt;常見Oracle HINT的用法：&lt;br /&gt;1. /*+ALL_ROWS*/&lt;br /&gt;表明對語句塊選擇基於開銷的優化方法,並獲得最佳吞吐量,使資源消耗最小化.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO=’SCOTT’;&lt;br /&gt;&lt;br /&gt;2. /*+FIRST_ROWS*/&lt;br /&gt;表明對語句塊選擇基於開銷的優化方法,並獲得最佳響應時間,使資源消耗最小化.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+FIRST_ROWS*/ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO=’SCOTT’;&lt;br /&gt;&lt;br /&gt;3. /*+CHOOSE*/&lt;br /&gt;表明如果數據字典中有訪問表的統計資料,將基於開銷的優化方法,並獲得最佳的吞吐量;&lt;br /&gt;表明如果數據字典中沒有訪問表的統計資料,將基於規則開銷的優化方法;&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+CHOOSE*/ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO=’SCOTT’;&lt;br /&gt;&lt;br /&gt;4. /*+RULE*/&lt;br /&gt;表明對語句塊選擇基於規則的優化方法.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+ RULE */ EMP_NO,EMP_NAM,DAT_IN FROM BSEMPMS WHERE EMP_NO=’SCOTT’;&lt;br /&gt;&lt;br /&gt;5. /*+FULL(TABLE)*/&lt;br /&gt;表明對表選擇全局掃描的方法.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+FULL(A)*/ EMP_NO,EMP_NAM FROM BSEMPMS A WHERE EMP_NO=’SCOTT’;&lt;br /&gt;&lt;br /&gt;6. /*+ROWID(TABLE)*/&lt;br /&gt;提示明確表明對指定表根據ROWID進行訪問.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+ROWID(BSEMPMS)*/ * FROM BSEMPMS WHERE ROWID&gt;=’AAAAAAAAAAAAAA’&lt;br /&gt;AND EMP_NO=’SCOTT’;&lt;br /&gt;&lt;br /&gt;7. /*+CLUSTER(TABLE)*/&lt;br /&gt;提示明確表明對指定表選擇簇掃描的訪問方法,它只對簇對像有效.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+CLUSTER */ BSEMPMS.EMP_NO,DPT_NO FROM BSEMPMS,BSDPTMS&lt;br /&gt;WHERE DPT_NO=’TEC304′ AND BSEMPMS.DPT_NO=BSDPTMS.DPT_NO;&lt;br /&gt;&lt;br /&gt;8. /*+INDEX(TABLE INDEX_NAME)*/&lt;br /&gt;表明對錶選擇索引的掃描方法.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+INDEX(BSEMPMS SEX_INDEX) USE SEX_INDEX BECAUSE THERE ARE FEWMALE BSEMPMS */ FROM BSEMPMS WHERE SEX=’M&#39;;&lt;br /&gt;&lt;br /&gt;9. /*+INDEX_ASC(TABLE INDEX_NAME)*/&lt;br /&gt;表明對錶選擇索引升序的掃描方法.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+INDEX_ASC(BSEMPMS PK_BSEMPMS) */ FROM BSEMPMS WHERE DPT_NO=’SCOTT’;&lt;br /&gt;&lt;br /&gt;10. /*+INDEX_COMBINE*/&lt;br /&gt;為指定表選擇位圖訪問路經,如果INDEX_COMBINE中沒有提供作為參數的索引,將選擇出位圖索引的布爾組合方式.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+INDEX_COMBINE(BSEMPMS SAL_BMI HIREDATE_BMI)*/ * FROM BSEMPMS&lt;br /&gt;WHERE SAL&lt;5000000 emp_no=&quot;SCOTT&quot; sex=&quot;M&quot; dpt_no=&quot;V.DPT_NO&quot;&gt;V.AVG_SAL;&lt;br /&gt;&lt;br /&gt;20. /*+NO_MERGE(TABLE)*/&lt;br /&gt;對於有可合併的視圖不再合併.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+NO_MERGE(V) */ A.EMP_NO,A.EMP_NAM,B.DPT_NO FROM BSEMPMS A (SELECT DPT_NO,AVG(SAL) AS AVG_SAL FROM BSEMPMS B GROUP BY DPT_NO) V WHERE A.DPT_NO=V.DPT_NO AND A.SAL&gt;V.AVG_SAL;&lt;br /&gt;&lt;br /&gt;21. /*+ORDERED*/&lt;br /&gt;根據表出現在FROM中的順序,ORDERED使ORACLE依此順序對其連接.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+ORDERED*/ A.COL1,B.COL2,C.COL3 FROM TABLE1 A,TABLE2 B,TABLE3 C WHERE A.COL1=B.COL1 AND B.COL1=C.COL1;&lt;br /&gt;&lt;br /&gt;22. /*+USE_NL(TABLE)*/&lt;br /&gt;將指定表與嵌套的連接的行源進行連接,並把指定表作為內部表.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+ORDERED USE_NL(BSEMPMS)*/ BSDPTMS.DPT_NO,BSEMPMS.EMP_NO,BSEMPMS.EMP_NAM FROM BSEMPMS,BSDPTMS WHERE BSEMPMS.DPT_NO=BSDPTMS.DPT_NO;&lt;br /&gt;&lt;br /&gt;23. /*+USE_MERGE(TABLE)*/&lt;br /&gt;將指定的表與其他行源通過合併排序連接方式連接起來.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+USE_MERGE(BSEMPMS,BSDPTMS)*/ * FROM BSEMPMS,BSDPTMS WHERE BSEMPMS.DPT_NO=BSDPTMS.DPT_NO;&lt;br /&gt;&lt;br /&gt;24. /*+USE_HASH(TABLE)*/&lt;br /&gt;將指定的表與其他行源通過hash連接方式連接起來.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+USE_HASH(BSEMPMS,BSDPTMS)*/ * FROM BSEMPMS,BSDPTMS WHERE BSEMPMS.DPT_NO=BSDPTMS.DPT_NO;&lt;br /&gt;&lt;br /&gt;25. /*+DRIVING_SITE(TABLE)*/&lt;br /&gt;強制與ORACLE所選擇的位置不同的表進行查詢執行.&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+DRIVING_SITE(DEPT)*/ * FROM BSEMPMS,DEPT@BSDPTMS WHERE BSEMPMS.DPT_NO=DEPT.DPT_NO;&lt;br /&gt;&lt;br /&gt;26. /*+LEADING(TABLE)*/&lt;br /&gt;將指定的表作為連接次序中的首表.&lt;br /&gt;&lt;br /&gt;27. /*+CACHE(TABLE)*/&lt;br /&gt;當進行 full scan 時,CACHE提示能夠將表的檢索塊放置在緩衝區緩存中最近最少列表LRU的最近使用端&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+FULL(BSEMPMS) CAHE(BSEMPMS) */ EMP_NAM FROM BSEMPMS;&lt;br /&gt;&lt;br /&gt;28. /*+NOCACHE(TABLE)*/&lt;br /&gt;當進行 full scan 時,CACHE提示能夠將表的檢索塊放置在緩衝區緩存中最近最少列表LRU的最近使用端&lt;br /&gt;例如:&lt;br /&gt;SELECT /*+FULL(BSEMPMS) NOCAHE(BSEMPMS) */ EMP_NAM FROM BSEMPMS;&lt;br /&gt;&lt;br /&gt;29. /*+APPEND*/&lt;br /&gt;直接插入到表的最後,可以提高速度.&lt;br /&gt;insert /*+append*/ into test1 select * from test4 ;&lt;br /&gt;&lt;br /&gt;30. /*+NOAPPEND*/&lt;br /&gt;通過在插入語句生存期內停止並行模式來啟動常規插入.&lt;br /&gt;insert /*+noappend*/ into test1 select * from test4 ;&lt;br /&gt;&lt;br /&gt;source: http://iqloss.blogspot.com/2011/04/oracle-hint.html</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/49860479958785995/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/49860479958785995' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/49860479958785995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/49860479958785995'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/10/oracle-hint.html' title='Oracle Hint'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-5474702408193966450</id><published>2011-10-18T01:49:00.000-07:00</published><updated>2011-10-18T01:50:00.062-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><category scheme="http://www.blogger.com/atom/ns#" term="MSSQL"/><title type='text'>五种提高 SQL 性能的方法</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;; background-color: rgb(255, 255, 255); font-size: medium; &quot;&gt;&lt;h1 style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 21px; margin-top: 12px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); &quot;&gt;五种提高 SQL 性能的方法&lt;/h1&gt;&lt;div class=&quot;date&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: rgb(102, 102, 102); margin-top: 9px; &quot;&gt;发布日期： 4/1/2004&lt;span class=&quot;datePipe&quot; style=&quot;color: rgb(204, 204, 204); &quot;&gt; | &lt;/span&gt;更新日期： 4/1/2004&lt;/div&gt;&lt;div class=&quot;overview&quot; style=&quot;padding-top: 10px; &quot;&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;Johnny Papa&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;&lt;a href=&quot;http://msdn.microsoft.com/msdnmag/columns/mmData.asp&quot; target=&quot;_blank&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;Data Points Archive&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;有时， 为了让应用程序运行得更快，所做的全部工作就是在这里或那里做一些很小调整。啊，但关键在于确定如何进行调整！迟早您会遇到这种情况：应用程序中的 SQL 查询不能按照您想要的方式进行响应。它要么不返回数据，要么耗费的时间长得出奇。如果它降低了报告或您的企业应用程序的速度，用户必须等待的时间过长，他们就会很不满意。就像您的父母不想听您解释为什么在深更半夜才回来一样，用户也不会听你解释为什么查询耗费这么长时间。（“对不起，妈妈，我使用了太多的 LEFT JOIN。”）用户希望应用程序响应迅速，他们的报告能够在瞬间之内返回分析数据。就我自己而言，如果在 Web 上冲浪时某个页面要耗费十多秒才能加载（好吧，五秒更实际一些），我也会很不耐烦。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;为了解决这些问题，重要的是找到问题的根源。那么，从哪里开始呢？根本原因通常在于数据库设计和访问它的查询。在本月的专栏中，我将讲述四项技术，这些技术可用于提高基于 SQL Server? 的应用程序的性能或改善其可伸缩性。我将仔细说明 LEFT JOIN、CROSS JOIN 的使用以及 IDENTITY 值的检索。请记住，根本没有神奇的解决方案。调整您的数据库及其查询需要占用时间、进行分析，还需要大量的测试。这些技术都已被证明行之有效，但对您的应用程序而言，可能其中一些技术比另一些技术更适用。&lt;/p&gt;&lt;/div&gt;&lt;center&gt;&lt;img src=&quot;http://img.microsoft.com/library/gallery/templates/MNP2.Common/images/3squares.gif&quot; border=&quot;0&quot; alt=&quot;*&quot; title=&quot;&quot; width=&quot;30&quot; height=&quot;6&quot; /&gt;&lt;/center&gt;&lt;div style=&quot;height: 18px; &quot;&gt;&lt;/div&gt;&lt;h5 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 2px; &quot;&gt;本页内容&lt;/h5&gt;&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; border=&quot;0&quot; style=&quot;margin-top: 7px; margin-bottom: 12px; &quot;&gt;&lt;tbody&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EZB&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;img width=&quot;7&quot; height=&quot;9&quot; hspace=&quot;4&quot; vspace=&quot;2&quot; border=&quot;0&quot; src=&quot;http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_down.gif&quot; alt=&quot;     从 INSERT 返回 IDENTITY    &quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class=&quot;onThisPage&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-left: 2px; padding-bottom: 8px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EZB&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;从 INSERT 返回 IDENTITY&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EFC&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;img width=&quot;7&quot; height=&quot;9&quot; hspace=&quot;4&quot; vspace=&quot;2&quot; border=&quot;0&quot; src=&quot;http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_down.gif&quot; alt=&quot;     内嵌视图与临时表    &quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class=&quot;onThisPage&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-left: 2px; padding-bottom: 8px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EFC&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;内嵌视图与临时表&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EMC&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;img width=&quot;7&quot; height=&quot;9&quot; hspace=&quot;4&quot; vspace=&quot;2&quot; border=&quot;0&quot; src=&quot;http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_down.gif&quot; alt=&quot;     避免 LEFT JOIN 和 NULL    &quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class=&quot;onThisPage&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-left: 2px; padding-bottom: 8px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EMC&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;避免 LEFT JOIN 和 NULL&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EBD&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;img width=&quot;7&quot; height=&quot;9&quot; hspace=&quot;4&quot; vspace=&quot;2&quot; border=&quot;0&quot; src=&quot;http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_down.gif&quot; alt=&quot;     灵活使用笛卡尔乘积    &quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class=&quot;onThisPage&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-left: 2px; padding-bottom: 8px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EBD&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;灵活使用笛卡尔乘积&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr valign=&quot;top&quot;&gt;&lt;td&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EWD&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;img width=&quot;7&quot; height=&quot;9&quot; hspace=&quot;4&quot; vspace=&quot;2&quot; border=&quot;0&quot; src=&quot;http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_down.gif&quot; alt=&quot;     拾遗补零    &quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class=&quot;onThisPage&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-left: 2px; padding-bottom: 8px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#EWD&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;拾遗补零&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;a name=&quot;EZB&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;/a&gt;&lt;h2 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; font-weight: bold; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 8px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; &quot;&gt;从 INSERT 返回 IDENTITY&lt;/h2&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;我决定从遇到许多问题的内容入手：如何在执行 SQL INSERT 后检索 IDENTITY 值。通常，问题不在于如何编写检索值的查询，而在于在哪里以及何时进行检索。在 SQL Server 中，下面的语句可用于检索由最新在活动数据库连接上运行的 SQL 语句所创建的 IDENTITY 值：&lt;/p&gt;&lt;pre class=&quot;codeSample&quot; style=&quot;background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); font-family: &#39;Lucida Console&#39;, &#39;Courier New&#39;; font-size: 11px; padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 25px; margin-bottom: 1em; background-position: initial initial; background-repeat: initial initial; &quot;&gt;SELECT @@IDENTITY&lt;/pre&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;这个 SQL 语句并不复杂，但需要记住的一点是：如果这个最新的 SQL 语句不是 INSERT，或者您针对非 INSERT SQL 的其他连接运行了此 SQL，则不会获得期望的值。您必须运行下列代码才能检索紧跟在 INSERT SQL 之后且位于同一连接上的 IDENTITY，如下所示：&lt;/p&gt;&lt;pre class=&quot;codeSample&quot; style=&quot;background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); font-family: &#39;Lucida Console&#39;, &#39;Courier New&#39;; font-size: 11px; padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 25px; margin-bottom: 1em; background-position: initial initial; background-repeat: initial initial; &quot;&gt;INSERT INTO Products (ProductName) VALUES (&#39;Chalk&#39;)  SELECT @@IDENTITY&lt;/pre&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;在一个连接上针对 Northwind 数据库运行这些查询将返回一个名称为 Chalk 的新产品的 IDENTITY 值。所以，在使用 ADO 的 Visual Basic? 应用程序中，可以运行以下语句：&lt;/p&gt;&lt;pre class=&quot;codeSample&quot; style=&quot;background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); font-family: &#39;Lucida Console&#39;, &#39;Courier New&#39;; font-size: 11px; padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 25px; margin-bottom: 1em; background-position: initial initial; background-repeat: initial initial; &quot;&gt;Set oRs = oCn.Execute(&quot;SET NOCOUNT ON;INSERT INTO Products _ (ProductName) VALUES (&#39;Chalk&#39;);SELECT @@IDENTITY&quot;)  lProductID = oRs(0)&lt;/pre&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;此代码告诉 SQL Server 不要返回查询的行计数，然后执行 INSERT 语句，并返回刚刚为这个新行创建的 IDENTITY 值。SET NOCOUNT ON 语句表示返回的记录集有一行和一列，其中包含了这个新的 IDENTITY 值。如果没有此语句，则会首先返回一个空的记录集（因为 INSERT 语句不返回任何数据），然后会返回第二个记录集，第二个记录集中包含 IDENTITY 值。这可能有些令人困惑，尤其是因为您从来就没有希望过 INSERT 会返回记录集。之所以会发生此情况，是因为 SQL Server 看到了这个行计数（即一行受到影响）并将其解释为表示一个记录集。因此，真正的数据被推回到了第二个记录集。当然您可以使用 ADO 中的 NextRecordset 方法获取此第二个记录集，但如果总能够首先返回该记录集且只返回该记录集，则会更方便，也更有效率。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;此方法虽然有效，但需要在 SQL 语句中额外添加一些代码。获得相同结果的另一方法是在 INSERT 之前使用 SET NOCOUNT ON 语句，并将 SELECT @@IDENTITY 语句放在表中的 FOR INSERT 触发器中，如下面的代码片段所示。这样，任何进入该表的 INSERT 语句都将自动返回 IDENTITY 值。&lt;/p&gt;&lt;pre class=&quot;codeSample&quot; style=&quot;background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); font-family: &#39;Lucida Console&#39;, &#39;Courier New&#39;; font-size: 11px; padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 25px; margin-bottom: 1em; background-position: initial initial; background-repeat: initial initial; &quot;&gt;CREATE TRIGGER trProducts_Insert ON Products FOR INSERT AS      SELECT @@IDENTITY  GO &lt;/pre&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;触发器只在 Products 表上发生 INSERT 时启动，所以它总是会在成功 INSERT 之后返回一个 IDENTITY。使用此技术，您可以始终以相同的方式在应用程序中检索 IDENTITY 值。&lt;/p&gt;&lt;div style=&quot;margin-top: 3px; margin-bottom: 10px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#top&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;img width=&quot;7&quot; height=&quot;9&quot; border=&quot;0&quot; src=&quot;http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_up.gif&quot; alt=&quot;返回页首&quot; /&gt;&lt;/a&gt;&lt;a class=&quot;topOfPage&quot; href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#top&quot; style=&quot;color: rgb(0, 51, 204); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-left: 4px; padding-right: 4px; &quot;&gt;返回页首&lt;/a&gt;&lt;/div&gt;&lt;a name=&quot;EFC&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;/a&gt;&lt;h2 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; font-weight: bold; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 8px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; &quot;&gt;内嵌视图与临时表&lt;/h2&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;某些时候，查询需要将数据与其他一些可能只能通过执行 GROUP BY 然后执行标准查询才能收集的数据进行联接。例如，如果要查询最新五个定单的有关信息，您首先需要知道是哪些定单。这可以使用返回定单 ID 的 SQL 查询来检索。此数据就会存储在临时表（这是一个常用技术）中，然后与 Products 表进行联接，以返回这些定单售出的产品数量：&lt;/p&gt;&lt;pre class=&quot;codeSample&quot; style=&quot;background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); font-family: &#39;Lucida Console&#39;, &#39;Courier New&#39;; font-size: 11px; padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 25px; margin-bottom: 1em; background-position: initial initial; background-repeat: initial initial; &quot;&gt;CREATE TABLE #Temp1 (OrderID INT NOT NULL, _                      OrderDate DATETIME NOT NULL)  INSERT INTO #Temp1 (OrderID, OrderDate) SELECT     TOP 5 o.OrderID, o.OrderDate FROM Orders o ORDER BY o.OrderDate DESC  SELECT     p.ProductName, SUM(od.Quantity) AS ProductQuantity FROM     #Temp1 t      INNER JOIN [Order Details] od ON t.OrderID = od.OrderID     INNER JOIN Products p ON od.ProductID = p.ProductID  GROUP BY p.ProductName ORDER BY p.ProductName  DROP TABLE #Temp1&lt;/pre&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;这些 SQL 语句会创建一个临时表，将数据插入该表中，将其他数据与该表进行联接，然后除去该临时表。这会导致此查询进行大量 I/O 操作，因此，可以重新编写查询，使用内嵌视图取代临时表。内嵌视图只是一个可以联接到 FROM 子句中的查询。所以，您不用在 tempdb 中的临时表上耗费大量 I/O 和磁盘访问，而可以使用内嵌视图得到同样的结果：&lt;/p&gt;&lt;pre class=&quot;codeSample&quot; style=&quot;background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); font-family: &#39;Lucida Console&#39;, &#39;Courier New&#39;; font-size: 11px; padding-top: 10px; padding-right: 15px; padding-bottom: 10px; padding-left: 25px; margin-bottom: 1em; background-position: initial initial; background-repeat: initial initial; &quot;&gt;SELECT p.ProductName,      SUM(od.Quantity) AS ProductQuantity FROM     (     SELECT TOP 5 o.OrderID, o.OrderDate     FROM     Orders o      ORDER BY o.OrderDate DESC     ) t      INNER JOIN [Order Details] od ON t.OrderID = od.OrderID     INNER JOIN Products p ON od.ProductID = p.ProductID  GROUP BY     p.ProductName ORDER BY     p.ProductName&lt;/pre&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;此查询不仅比前面的查询效率更高，而且长度更短。临时表会消耗大量资源。如果只需要将数据联接到其他查询，则可以试试使用内嵌视图，以节省资源。&lt;/p&gt;&lt;div style=&quot;margin-top: 3px; margin-bottom: 10px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#top&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;img width=&quot;7&quot; height=&quot;9&quot; border=&quot;0&quot; src=&quot;http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_up.gif&quot; alt=&quot;返回页首&quot; /&gt;&lt;/a&gt;&lt;a class=&quot;topOfPage&quot; href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#top&quot; style=&quot;color: rgb(0, 51, 204); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-left: 4px; padding-right: 4px; &quot;&gt;返回页首&lt;/a&gt;&lt;/div&gt;&lt;a name=&quot;EMC&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;/a&gt;&lt;h2 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; font-weight: bold; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 8px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; &quot;&gt;避免 LEFT JOIN 和 NULL&lt;/h2&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;当然，有很多时候您需要执行 LEFT JOIN 和使用 NULL 值。但是，它们并不适用于所有情况。改变 SQL 查询的构建方式可能会产生将一个花几分钟运行的报告缩短到只花几秒钟这样的天壤之别的效果。有时，必须在查询中调整数据的形态，使之适应应用程序所要求的显示方式。虽然 TABLE 数据类型会减少大量占用资源的情况，但在查询中还有许多区域可以进行优化。SQL 的一个有价值的常用功能是 LEFT JOIN。它可以用于检索第一个表中的所有行、第二个表中所有匹配的行、以及第二个表中与第一个表不匹配的所有行。例如，如果希望返回每个客户及其定单，使用 LEFT JOIN 则可以显示有定单和没有定单的客户。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;此工具可能会被过度使用。LEFT JOIN 消耗的资源非常之多，因为它们包含与 NULL（不存在）数据匹配的数据。在某些情况下，这是不可避免的，但是代价可能非常高。LEFT JOIN 比 INNER JOIN 消耗资源更多，所以如果您可以重新编写查询以使得该查询不使用任何 LEFT JOIN，则会得到非常可观的回报（请参阅图 1 中的图）。&lt;/p&gt;&lt;div style=&quot;width: 109px; &quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/art/5wayfig01.gif&quot; alt=&quot;&quot; width=&quot;109&quot; height=&quot;160&quot; /&gt;&lt;br /&gt;&lt;p class=&quot;figureCaption&quot; style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 12px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;&lt;b&gt;图&lt;/b&gt;&lt;b&gt; 1&lt;/b&gt;&lt;b&gt;：&lt;/b&gt;&lt;b&gt;查询&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;figureRule&quot; style=&quot;height: 1px; overflow-x: hidden; overflow-y: hidden; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(204, 204, 204); margin-top: 7px; margin-right: 0px; margin-bottom: 18px; margin-left: 0px; background-position: initial initial; background-repeat: initial initial; &quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;加快使用 LEFT JOIN 的查询速度的一项技术涉及创建一个 TABLE 数据类型，插入第一个表（LEFT JOIN 左侧的表）中的所有行，然后使用第二个表中的值更新 TABLE 数据类型。此技术是一个两步的过程，但与标准的 LEFT JOIN 相比，可以节省大量时间。一个很好的规则是尝试各种不同的技术并记录每种技术所需的时间，直到获得用于您的应用程序的执行性能最佳的查询。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;测试查询的速度时，有必要多次运行此查询，然后取一个平均值。因为查询（或存储过程）可能会存储在 SQL Server 内存中的过程缓存中，因此第一次尝试耗费的时间好像稍长一些，而所有后续尝试耗费的时间都较短。另外，运行您的查询时，可能正在针对相同的表运行其他查询。当其他查询锁定和解锁这些表时，可能会导致您的查询要排队等待。例如，如果您进行查询时某人正在更新此表中的数据，则在更新提交时您的查询可能需要耗费更长时间来执行。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;避免使用 LEFT JOIN 时速度降低的最简单方法是尽可能多地围绕它们设计数据库。例如，假设某一产品可能具有类别也可能没有类别。如果 Products 表存储了其类别的 ID，而没有用于某个特定产品的类别，则您可以在字段中存储 NULL 值。然后您必须执行 LEFT JOIN 来获取所有产品及其类别。您可以创建一个值为“No Category”的类别，从而指定外键关系不允许 NULL 值。通过执行上述操作，现在您就可以使用 INNER JOIN 检索所有产品及其类别了。虽然这看起来好像是一个带有多余数据的变通方法，但可能是一个很有价值的技术，因为它可以消除 SQL 批处理语句中消耗资源较多的 LEFT JOIN。在数据库中全部使用此概念可以为您节省大量的处理时间。请记住，对于您的用户而言，即使几秒钟的时间也非常重要，因为当您有许多用户正在访问同一个联机数据库应用程序时，这几秒钟实际上的意义会非常重大。&lt;/p&gt;&lt;div style=&quot;margin-top: 3px; margin-bottom: 10px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#top&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;img width=&quot;7&quot; height=&quot;9&quot; border=&quot;0&quot; src=&quot;http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_up.gif&quot; alt=&quot;返回页首&quot; /&gt;&lt;/a&gt;&lt;a class=&quot;topOfPage&quot; href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#top&quot; style=&quot;color: rgb(0, 51, 204); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-left: 4px; padding-right: 4px; &quot;&gt;返回页首&lt;/a&gt;&lt;/div&gt;&lt;a name=&quot;EBD&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;/a&gt;&lt;h2 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; font-weight: bold; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 8px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; &quot;&gt;灵活使用笛卡尔乘积&lt;/h2&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;对于此技巧，我将进行非常详细的介绍，并提倡在某些情况下使用笛卡尔乘积。出于某些原因，笛卡尔乘积 (CROSS JOIN) 遭到了很多谴责，开发人员通常会被警告根本就不要使用它们。在许多情况下，它们消耗的资源太多，从而无法高效使用。但是像 SQL 中的任何工具一样，如果正确使用，它们也会很有价值。例如，如果您想运行一个返回每月数据（即使某一特定月份客户没有定单也要返回）的查询，您就可以很方便地使用笛卡尔乘积。&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/art/figures3.html&quot; target=&quot;_blank&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt; 图 2 &lt;/a&gt;中的 SQL 就执行了上述操作。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;虽然这看起来好像没什么神奇的，但是请考虑一下，如果您从客户到定单（这些定单按月份进行分组并对销售额进行小计）进行了标准的 INNER JOIN，则只会获得客户有定单的月份。因此，对于客户未订购任何产品的月份，您不会获得 0 值。如果您想为每个客户都绘制一个图，以显示每个月和该月销售额，则可能希望此图包括月销售额为 0 的月份，以便直观标识出这些月份。如果使用 &lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/art/figures3.html&quot; target=&quot;_blank&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;图 2 &lt;/a&gt;中的 SQL，数据则会跳过销售额为 0 美元的月份，因为在定单表中对于零销售额不会包含任何行（假设您只存储发生的事件）。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/art/figures3.html&quot; target=&quot;_blank&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;图 3 &lt;/a&gt;中的代码虽然较长，但是可以达到获取所有销售数据（甚至包括没有销售额的月份）的目标。首先，它会提取去年所有月份的列表，然后将它们放入第一个 TABLE 数据类型表 (@tblMonths) 中。下一步，此代码会获取在该时间段内有销售额的所有客户公司的名称列表，然后将它们放入另一个 TABLE 数据类型表 (@tblCus-tomers) 中。这两个表存储了创建结果集所必需的所有基本数据，但实际销售数量除外。 第一个表中列出了所有月份（12 行），第二个表中列出了这个时间段内有销售额的所有客户（对于我是 81 个）。并非每个客户在过去 12 个月中的每个月都购买了产品，所以，执行 INNER JOIN 或 LEFT JOIN 不会返回每个月的每个客户。这些操作只会返回购买产品的客户和月份。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;笛卡尔乘积则可以返回所有月份的所有客户。笛卡尔乘积基本上是将第一个表与第二个表相乘，生成一个行集合，其中包含第一个表中的行数与第二个表中的行数相乘的结果。因此，笛卡尔乘积会向表 @tblFinal 返回 972 行。最后的步骤是使用此日期范围内每个客户的月销售额总计更新 @tblFinal 表，以及选择最终的行集。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;如果由于笛卡尔乘积占用的资源可能会很多，而不需要真正的笛卡尔乘积，则可以谨慎地使用 CROSS JOIN。例如，如果对产品和类别执行了 CROSS JOIN，然后使用 WHERE 子句、DISTINCT 或 GROUP BY 来筛选出大多数行，那么使用 INNER JOIN 会获得同样的结果，而且效率高得多。如果需要为所有的可能性都返回数据（例如在您希望使用每月销售日期填充一个图表时），则笛卡尔乘积可能会非常有帮助。但是，您不应该将它们用于其他用途，因为在大多数方案中 INNER JOIN 的效率要高得多。&lt;/p&gt;&lt;div style=&quot;margin-top: 3px; margin-bottom: 10px; &quot;&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#top&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;img width=&quot;7&quot; height=&quot;9&quot; border=&quot;0&quot; src=&quot;http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_up.gif&quot; alt=&quot;返回页首&quot; /&gt;&lt;/a&gt;&lt;a class=&quot;topOfPage&quot; href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx#top&quot; style=&quot;color: rgb(0, 51, 204); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; padding-left: 4px; padding-right: 4px; &quot;&gt;返回页首&lt;/a&gt;&lt;/div&gt;&lt;a name=&quot;EWD&quot; style=&quot;color: rgb(0, 51, 204); &quot;&gt;&lt;/a&gt;&lt;h2 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 15px; font-weight: bold; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 8px; padding-right: 0px; padding-bottom: 4px; padding-left: 0px; &quot;&gt;拾遗补零&lt;/h2&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;这里介绍其他一些可帮助提高 SQL 查询效率的常用技术。假设您将按区域对所有销售人员进行分组并将他们的销售额进行小计，但是您只想要那些数据库中标记为处于活动状态的销售人员。您可以按区域对销售人员分组，并使用 HAVING 子句消除那些未处于活动状态的销售人员，也可以在 WHERE 子句中执行此操作。在 WHERE 子句中执行此操作会减少需要分组的行数，所以比在 HAVING 子句中执行此操作效率更高。HAVING 子句中基于行的条件的筛选会强制查询对那些在 WHERE 子句中会被去除的数据进行分组。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;另一个提高效率的技巧是使用 DISTINCT 关键字查找数据行的单独报表，来代替使用 GROUP BY 子句。在这种情况下，使用 DISTINCT 关键字的 SQL 效率更高。请在需要计算聚合函数（SUM、COUNT、MAX 等）的情况下再使用 GROUP BY。另外，如果您的查询总是自己返回一个唯一的行，则不要使用 DISTINCT 关键字。在这种情况下，DISTINCT 关键字只会增加系统开销。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;您已经看到了，有大量技术都可用于优化查询和实现特定的业务规则，技巧就是进行一些尝试，然后比较它们的性能。最重要的是要测试、测试、再测试。在此专栏的将来各期内容中，我将继续深入讲述 SQL Server 概念，包括数据库设计、好的索引实践以及 SQL Server 安全范例。&lt;/p&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;a href=&quot;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx?mfr=true&quot;&gt;http://www.microsoft.com/china/MSDN/library/data/sqlserver/FiveWaystoRevupYourSQLPerformanCE.mspx?mfr=true&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;; background-color: rgb(255, 255, 255); font-size: medium; &quot;&gt;&lt;p style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 15px; padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;source: &lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/5474702408193966450/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/5474702408193966450' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5474702408193966450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5474702408193966450'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/10/sql.html' title='五种提高 SQL 性能的方法'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-3244759871862627731</id><published>2011-10-17T00:29:00.000-07:00</published><updated>2011-10-17T00:30:12.219-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><category scheme="http://www.blogger.com/atom/ns#" term="MSSQL"/><title type='text'>Combine Multiple Columns And Records In MSSQL</title><content type='html'>&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(85, 85, 85); font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-color: rgb(244, 243, 232); &quot;&gt;source: &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;a href=&quot;http://csharpdotnetfreak.blogspot.com/2009/07/mssql-combine-columns-comma-separated.html&quot;&gt;http://csharpdotnetfreak.blogspot.com/2009/07/mssql-combine-columns-comma-separated.html&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(85, 85, 85); font-family: Arial, Helvetica, sans-serif; background-color: rgb(244, 243, 232); &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;In this example i am going to describe how to combine multiple columns and records in one column in MS SQL.&lt;br /&gt;&lt;br /&gt;Here is the scenario&lt;br /&gt;&lt;br /&gt;I have a table having Employees names and their respective Department names, now i want to show Employees names separated by comma into one column and respective Department name in another column.&lt;br /&gt;&lt;br /&gt;My table schema is shown in the image below&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;font-size: 12px; clear: both; text-align: center; &quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgibVaU5VO4ejdc8NfSNGS0dJP_66ck6JDlfWDEjZzaLO6KJhVvRGhlL5gnHkhwt8AyKuMdVLgXZF5ZXCXoA1LFZlQg-YU9KCzwnFBZBYXUwxW3xaTpmvFPgQM1Da2GHVIFQ2bNz_-nji0G/s1600-h/1.JPG&quot; imageanchor=&quot;1&quot; target=&quot;_blank&quot; style=&quot;color: rgb(179, 0, 0); text-decoration: none; outline-style: none; outline-width: initial; outline-color: initial; margin-left: 1em; margin-right: 1em; &quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgibVaU5VO4ejdc8NfSNGS0dJP_66ck6JDlfWDEjZzaLO6KJhVvRGhlL5gnHkhwt8AyKuMdVLgXZF5ZXCXoA1LFZlQg-YU9KCzwnFBZBYXUwxW3xaTpmvFPgQM1Da2GHVIFQ2bNz_-nji0G/s400/1.JPG&quot; style=&quot;border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; &quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span class=&quot;fullpost&quot; style=&quot;display: inline; &quot;&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 12px;&quot;&gt;And this is Data into table&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;font-size: 12px; clear: both; text-align: center; &quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIRmPzD_yRaKeuMCoa0jJVpUM8Z4UbCBOoWdiMmaJhhkUUqvZUztPFd8Ghb9PRCRy98OPEGCQ66j3CisydWXfi84p0Fl71SQA92TmKrRM8gXlulmyH71Gdd4ffRxUnEvSiMnRw2YsUbA9Q/s1600-h/2.JPG&quot; imageanchor=&quot;1&quot; target=&quot;_blank&quot; style=&quot;color: rgb(179, 0, 0); text-decoration: none; outline-style: none; outline-width: initial; outline-color: initial; margin-left: 1em; margin-right: 1em; &quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIRmPzD_yRaKeuMCoa0jJVpUM8Z4UbCBOoWdiMmaJhhkUUqvZUztPFd8Ghb9PRCRy98OPEGCQ66j3CisydWXfi84p0Fl71SQA92TmKrRM8gXlulmyH71Gdd4ffRxUnEvSiMnRw2YsUbA9Q/s400/2.JPG&quot; style=&quot;border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; &quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;I want output in following format&lt;br /&gt;&lt;br /&gt;&lt;b&gt;                                  Department                               FirstName&lt;br /&gt;                                   IT                                             amiT,Emp1,Emp5&lt;br /&gt;                                  Admin                                       Shobhit, Emp3,Emp7&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;and so on&lt;br /&gt;&lt;br /&gt;To get this desired result we need to write below mentioned query&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;pre class=&quot;brush:sql&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;b&gt;SELECT DISTINCT Department, EmpNames = substring( ( SELECT &#39;, &#39; + FirstName  FROM Employees e2 WHERE e2.Department = e1.Department FOR XML path(&#39;&#39;), elements  ),2,500) FROM Employees e1&lt;/b&gt; &lt;/span&gt;&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; &gt;&lt;br /&gt;And the output of this SQL Query would be&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;font-size: 12px; clear: both; text-align: center; &quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg809cKvOCqy37osl75QUgC_ZviHryu1QoHwRqltYHp_wAnFL3ByqrxPzGwjjRtANpDvfvzGcUodyc6ega4wyv8tqO6zdBYzsDTK4otUEHU4KUsKqYpEmKiaQWlg5PNZ3Bh2b0xWa-9DhXQ/s1600-h/3.JPG&quot; imageanchor=&quot;1&quot; target=&quot;_blank&quot; style=&quot;color: rgb(179, 0, 0); text-decoration: none; outline-style: none; outline-width: initial; outline-color: initial; margin-left: 1em; margin-right: 1em; &quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg809cKvOCqy37osl75QUgC_ZviHryu1QoHwRqltYHp_wAnFL3ByqrxPzGwjjRtANpDvfvzGcUodyc6ega4wyv8tqO6zdBYzsDTK4otUEHU4KUsKqYpEmKiaQWlg5PNZ3Bh2b0xWa-9DhXQ/s400/3.JPG&quot; style=&quot;border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; &quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/3244759871862627731/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/3244759871862627731' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/3244759871862627731'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/3244759871862627731'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/10/combine-multiple-columns-and-records-in.html' title='Combine Multiple Columns And Records In MSSQL'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgibVaU5VO4ejdc8NfSNGS0dJP_66ck6JDlfWDEjZzaLO6KJhVvRGhlL5gnHkhwt8AyKuMdVLgXZF5ZXCXoA1LFZlQg-YU9KCzwnFBZBYXUwxW3xaTpmvFPgQM1Da2GHVIFQ2bNz_-nji0G/s72-c/1.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-7332371456068193656</id><published>2011-10-12T08:57:00.000-07:00</published><updated>2011-10-12T08:59:52.411-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS"/><title type='text'>[iOS開發] 如何做一個Username/Password彈跳視窗(UIAlertView)?</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 51); font-family: &#39;Lucida Grande&#39;, Verdana, Arial, sans-serif; line-height: 22px; background-color: rgb(221, 221, 221); &quot;&gt;&lt;p style=&quot;font-size: 1.05em; &quot;&gt;&lt;img src=&quot;http://lh6.ggpht.com/_W-5oCUN3-sQ/TRn_ogeaBjI/AAAAAAAAD9c/XhX0sVjcwjU/s800/iphone_login_dialog.png&quot; alt=&quot;&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; max-width: 100%; &quot; /&gt;&lt;/p&gt;&lt;ol style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 35px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;&lt;li style=&quot;text-align: left;list-style-type: decimal; list-style-position: outside; list-style-image: initial; margin-top: 7px; margin-right: 0px; margin-bottom: 8px; margin-left: 10px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; &quot;&gt;首先，你要初始化一個UIAlertView物件。然後你必須將message的參數值設為@”\n\n\n”，這是用來多留幾行空白以便擺放輸入框欄位。&lt;/li&gt;&lt;li style=&quot;list-style-type: decimal; list-style-position: outside; list-style-image: initial; margin-top: 7px; margin-right: 0px; margin-bottom: 8px; margin-left: 10px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; &quot;&gt;建立兩個UITextField物件，將他們加至UIAlertView裡成為subview。別忘了設定輸入框的背景色(setBackgroundColor)、預設文字(setPlaceholder)、安全表示(setSecureTextEntry，輸入文字時會變成星號，用於密碼欄)。&lt;/li&gt;&lt;li style=&quot;list-style-type: decimal; list-style-position: outside; list-style-image: initial; margin-top: 7px; margin-right: 0px; margin-bottom: 8px; margin-left: 10px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; &quot;&gt;最後，在呈現UIAlertView時，在垂直位移加上一點Shift值並且有需要的話將之設定為FirstResponder。&lt;/li&gt;&lt;/ol&gt;&lt;p style=&quot;font-size: 1.05em; &quot;&gt;Source Code:&lt;/p&gt;&lt;div class=&quot;syntaxhighlighter &quot; id=&quot;highlighter_738167&quot; style=&quot;margin-top: 1em !important; margin-right: 0px !important; margin-bottom: 1em !important; margin-left: 0px !important; padding-top: 1px !important; padding-right: 1px !important; padding-bottom: 1px !important; padding-left: 1px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(231, 229, 220) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: relative !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 944px; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;div class=&quot;bar&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;div class=&quot;toolbar&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 8px !important; padding-right: 8px !important; padding-bottom: 8px !important; padding-left: 0px !important; border-top-width: 1px !important; border-right-width: 1px !important; border-bottom-width: 1px !important; border-left-width: 1px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: absolute !important; left: auto !important; top: 0px !important; right: 0px !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1px !important; border-top-color: rgb(231, 229, 220) !important; border-right-color: rgb(231, 229, 220) !important; border-bottom-color: rgb(231, 229, 220) !important; border-left-color: rgb(231, 229, 220) !important; border-top-style: solid !important; border-right-style: solid !important; border-bottom-style: solid !important; border-left-style: solid !important; &quot;&gt;&lt;a href=&quot;http://fstoke.me/blog/?p=2643#viewSource&quot; title=&quot;view source&quot; class=&quot;item viewSource&quot; style=&quot;color: rgb(160, 160, 160) !important; text-decoration: none; display: block !important; float: left !important; margin-left: 8px !important; overflow-x: hidden !important; overflow-y: hidden !important; text-indent: -5000px !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/page_white_code.png) !important; width: 16px; height: 16px; background-repeat: no-repeat no-repeat !important; &quot;&gt;view source&lt;/a&gt;&lt;a href=&quot;http://fstoke.me/blog/?p=2643#printSource&quot; title=&quot;print&quot; class=&quot;item printSource&quot; style=&quot;color: rgb(160, 160, 160) !important; text-decoration: none; display: block !important; float: left !important; margin-left: 8px !important; overflow-x: hidden !important; overflow-y: hidden !important; text-indent: -5000px !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/printer.png) !important; width: 16px; height: 16px; background-repeat: no-repeat no-repeat !important; &quot;&gt;print&lt;/a&gt;&lt;a href=&quot;http://fstoke.me/blog/?p=2643#about&quot; title=&quot;?&quot; class=&quot;item about&quot; style=&quot;color: rgb(160, 160, 160) !important; text-decoration: none; display: block !important; float: left !important; margin-left: 8px !important; overflow-x: hidden !important; overflow-y: hidden !important; text-indent: -5000px !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/help.png) !important; width: 16px; height: 16px; background-repeat: no-repeat no-repeat !important; &quot;&gt;?&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;lines&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;01.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;UITextField *textField;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;02.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;UITextField *textField2;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;03.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;04.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;UIAlertView *prompt = [[UIAlertView alloc] initWithTitle:@&lt;/code&gt;&lt;code class=&quot;string&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: blue !important; &quot;&gt;&quot;Username and password&quot;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;05.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 441px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;message:@&lt;/code&gt;&lt;code class=&quot;string&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: blue !important; &quot;&gt;&quot;\n\n\n&quot;&lt;/code&gt; &lt;code class=&quot;comments&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 130, 0) !important; &quot;&gt;// IMPORTANT&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;06.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 432px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;delegate:nil&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;07.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 351px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;cancelButtonTitle:@&lt;/code&gt;&lt;code class=&quot;string&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: blue !important; &quot;&gt;&quot;Cancel&quot;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;08.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 351px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;otherButtonTitles:@&lt;/code&gt;&lt;code class=&quot;string&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: blue !important; &quot;&gt;&quot;Enter&quot;&lt;/code&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;, nil];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;09.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;10.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;textField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 50.0, 260.0, 25.0)];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;11.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[textField setBackgroundColor:[UIColor whiteColor]];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;12.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[textField setPlaceholder:@&lt;/code&gt;&lt;code class=&quot;string&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: blue !important; &quot;&gt;&quot;username&quot;&lt;/code&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;13.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[prompt addSubview:textField];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;14.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;15.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;textField2 = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 85.0, 260.0, 25.0)];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;16.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[textField2 setBackgroundColor:[UIColor whiteColor]];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;17.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[textField2 setPlaceholder:@&lt;/code&gt;&lt;code class=&quot;string&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: blue !important; &quot;&gt;&quot;password&quot;&lt;/code&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;18.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[textField2 setSecureTextEntry:YES];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;19.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[prompt addSubview:textField2];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;20.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;21.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;comments&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 130, 0) !important; &quot;&gt;// set place&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;22.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[prompt setTransform:CGAffineTransformMakeTranslation(0.0, 110.0)];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;23.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[prompt show];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;24.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[prompt release];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;25.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt2&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;26.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(248, 248, 248) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;comments&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 130, 0) !important; &quot;&gt;// set cursor and show keyboard&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;line alt1&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; &quot;&gt;&lt;code class=&quot;number&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0.3em !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: right !important; float: left !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: 3em !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; color: rgb(92, 92, 92) !important; &quot;&gt;27.&lt;/code&gt;&lt;span class=&quot;content&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 3.3em !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 3px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: rgb(255, 255, 255) !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; border-left-style: solid !important; border-left-color: rgb(108, 226, 108) !important; color: rgb(0, 0, 0) !important; &quot;&gt;&lt;span class=&quot;block&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 1.5em !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: url(http://fstoke.me/blog/wp-content/plugins/syntaxhighlighter-plus/syntaxhighlighter/styles/wrapping.png) !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; display: block !important; text-indent: -1.5em !important; background-position: 0px 1.1em !important; background-repeat: no-repeat no-repeat !important; &quot;&gt;&lt;code class=&quot;plain&quot; style=&quot;margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-style: initial !important; border-color: initial !important; outline-width: 0px !important; outline-style: initial !important; outline-color: initial !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; text-align: left !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; line-height: 1.1em !important; font-family: Consolas, Monaco, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace !important; font-style: normal !important; font-size: 1em !important; color: rgb(0, 0, 0) !important; &quot;&gt;[textField becomeFirstResponder];&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;font-size: 1.05em; &quot;&gt;Reference:&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 51); font-family: &#39;Lucida Grande&#39;, Verdana, Arial, sans-serif; font-size: 17px; line-height: 22px; background-color: rgb(221, 221, 221); &quot;&gt;&lt;a target=&quot;_blank&quot; href=&quot;http://iphone-dev-tips.alterplay.com/2009/12/username-and-password-uitextfields-in.html&quot; style=&quot;color: rgb(0, 102, 204); text-decoration: none; &quot;&gt;http://iphone-dev-tips.alterplay.com/2009/12/username-and-password-uitextfields-in.html&lt;/a&gt;&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;http://fstoke.me/blog/?p=2643&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/7332371456068193656/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/7332371456068193656' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/7332371456068193656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/7332371456068193656'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/10/ios-usernamepassworduialertview.html' title='[iOS開發] 如何做一個Username/Password彈跳視窗(UIAlertView)?'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/_W-5oCUN3-sQ/TRn_ogeaBjI/AAAAAAAAD9c/XhX0sVjcwjU/s72-c/iphone_login_dialog.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-1341264668714141796</id><published>2011-08-29T01:53:00.000-07:00</published><updated>2011-08-29T01:54:14.757-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><title type='text'>oracle查询效率积累</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 51); font-family: &#39;courier new&#39;, courier; font-size: 13px; line-height: 26px; background-color: rgb(255, 255, 255); &quot;&gt;&lt;strong&gt;（1）&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;选择最有效率的表名顺序&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;只在基于规则的优化器中有效&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); &quot;&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 36pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;ORACLE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;的解析器按照从右到左的顺序处理&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子句中的表名，&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子句中写在最后的表&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;基础表&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; driving table)&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;将被最先处理，在&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子句中包含多个表的情况下&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;你必须选择记录条数最少的表作为基础表。如果有&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;个以上的表连接查询&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;那就需要选择交叉表&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;(intersection table)&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;作为基础表&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;交叉表是指那个被其他表所引用的表&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（2）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;子句中的连接顺序．：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 36pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;ORACLE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;采用自下而上的顺序解析&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子句&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;根据这个原理&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;表之间的连接必须写在其他&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;条件之前&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;那些可以过滤掉最大数量记录的条件必须写在&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子句的末尾&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（3）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;子句中避免使用&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt; ‘ * ‘&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 36pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;ORACLE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;在解析的过程中&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;会将&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;&#39;*&#39; &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;依次转换成所有的列名&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;这个工作是通过查询数据字典完成的&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;这意味着将耗费更多的时间&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（4）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;减少访问数据库的次数：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 15pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;ORACLE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;在内部执行了许多工作&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;: &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;解析&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;SQL&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;语句&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;估算索引的利用率&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;绑定变量&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; , &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;读数据块等；&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（5）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: blue; &quot;&gt;在&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;SQL*Plus , SQL*Forms&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;和&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;Pro*C&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;中重新设置&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;ARRAYSIZE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;参数&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;可以增加每次数据库访问的检索数据量&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; ,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;建议值为&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;200&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（6）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;使用&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;DECODE&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;函数来减少处理时间：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 15pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;使用&lt;/span&gt;&lt;span style=&quot;color: red; &quot;&gt;DECODE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;函数可以避免重复扫描相同记录或重复连接相同的表&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（7）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;整合简单&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;无关联的数据库访问：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 15pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;如果你有几个简单的数据库查询语句&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;你可以把它们整合到一个查询中&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;即使它们之间没有关系&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（8）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;删除重复记录&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 15pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;最高效的删除重复记录方法&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; ( &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;因为使用了&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;ROWID)&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;例子：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;DELETE FROM EMP E WHERE E.ROWID &amp;gt; (SELECT MIN(X.ROWID)&lt;br /&gt;FROM EMP X WHERE X.EMP_NO = E.EMP_NO);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（9）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;用&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;TRUNCATE&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;替代&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;DELETE&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;当删除表中的记录时&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;在通常情况下&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;回滚段&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;(rollback segments ) &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;用来存放可以被恢复的信息&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;如果你没有&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;COMMIT&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;事务&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,ORACLE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;会将数据恢复到删除之前的状态&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;准确地说是&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;恢复到执行删除命令之前的状况&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;而当运用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;TRUNCATE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;时&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;回滚段不再存放任何可被恢复的信息&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;当命令运行后&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;数据不能被恢复&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;因此很少的资源被调用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;执行时间也会很短&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. (&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;译者按&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;: TRUNCATE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;只在删除全表适用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,TRUNCATE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;是&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;DDL&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;不是&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;DML)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（10）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;尽量多使用&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;COMMIT&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;只要有可能&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;在程序中尽量多使用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;COMMIT, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;这样程序的性能得到提高&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;需求也会因为&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;COMMIT&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;所释放的资源而减少&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;:&lt;br /&gt;COMMIT&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;所释放的资源&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;:&lt;br /&gt;a. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;回滚段上用于恢复数据的信息&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;br /&gt;b. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;被程序语句获得的锁&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;&lt;br /&gt;c. redo log buffer &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;中的空间&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;&lt;br /&gt;d. ORACLE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;为管理上述&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;种资源中的内部花费&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（11）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;用&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;Where&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;子句替换&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;HAVING&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;子句：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;避免使用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;HAVING&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子句&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, HAVING &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;只会在检索出所有记录之后才对结果集进行过滤&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;这个处理需要排序&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;总计等操作&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;如果能通过&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子句限制记录的数目&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;那就能减少这方面的开销&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt; &lt;span style=&quot;color: blue; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;非&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;oracle&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;中&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;on&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;、&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;where&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;、&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;having&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;这三个都可以加条件的子句中，&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;on&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;是最先执行，&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;where&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;次之，&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;having&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;最后，因为&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;on&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;是先把不符合条件的记录过滤后才进行统计，它就可以减少中间运算要处理的数据，按理说应该速度是最快的，&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;where&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;也应该比&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;having&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;快点的，因为它过滤数据后才进行&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;sum&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;，在两个表联接时才用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;on&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;的，所以在一个表的时候，就剩下&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;where&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;跟&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;having&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;比较了。在这单表查询统计的情况下，如果要过滤的条件没有涉及到要计算字段，那它们的结果是一样的，只是&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;where&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;可以使用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;rushmore&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;技术，而&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;having&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;就不能，在速度上后者要慢如果要涉及到计算的字段，就表示在没计算之前，这个字段的值是不确定的，根据上篇写的工作流程，&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;where&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;的作用时间是在计算之前就完成的，而&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;having&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;就是在计算后才起作用的，所以在这种情况下，两者的结果会不同。在多表联接查询时，&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;on&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;比&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;where&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;更早起作用。系统首先根据各个表之间的联接条件，把多个表合成一个临时表后，再由&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;where&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;进行过滤，然后再计算，计算完后再由&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;having&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;进行过滤。由此可见，要想过滤条件起到正确的作用，首先要明白这个条件应该在什么时候起作用，然后再决定放在那里&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（12）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;减少对表的查询：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 15pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;在含有子查询的&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;SQL&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;语句中&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;要特别注意减少对表的查询&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;例子：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;     &lt;/span&gt;&lt;span style=&quot;color: rgb(153, 51, 102); &quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; TAB_NAME &lt;/span&gt;&lt;span style=&quot;color: rgb(153, 51, 102); &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; TABLES &lt;/span&gt;&lt;span style=&quot;color: rgb(153, 51, 102); &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; (TAB_NAME,DB_VER) = ( &lt;/span&gt;&lt;span style=&quot;color: rgb(153, 51, 102); &quot;&gt;SELECT&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;TAB_NAME,DB_VER &lt;/span&gt;&lt;span style=&quot;color: rgb(153, 51, 102); &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; TAB_COLUMNS &lt;/span&gt;&lt;span style=&quot;color: rgb(153, 51, 102); &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; VERSION = 604)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（13）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;通过内部函数提高&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;SQL&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;效率&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;复杂的&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;SQL&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;往往牺牲了执行效率&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;能够掌握上面的运用函数解决问题的方法在实际工作中是非常有意义的&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（14）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;使用表的别名&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;(Alias)&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;当在&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;SQL&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;语句中连接多个表时&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;请使用表的别名并把别名前缀于每个&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;Column&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;上&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;这样一来&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;就可以减少解析的时间并减少那些由&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;Column&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;歧义引起的语法错误&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（15）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;用&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;EXISTS&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;替代&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;I&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;N&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;、&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;用&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;NOT EXISTS&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;替代&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;NOT IN&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;在许多基于基础表的查询中&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;为了满足一个条件&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;往往需要对另一个表进行联接&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;在这种情况下&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;使用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;EXISTS(&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;或&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;NOT EXISTS)&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;通常将提高查询的效率&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;在子查询中&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,NOT IN&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子句将执行一个内部的排序和合并&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;无论在哪种情况下&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,NOT IN&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;都是最低效的&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;因为它对子查询中的表执行了一个全表遍历&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;). &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;为了避免使用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;NOT IN ,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;我们可以把它改写成外连接&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;(Outer Joins)&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;或&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;NOT EXISTS.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;例子：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: teal; &quot;&gt;（&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;高效&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;）&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; * &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; EMP (&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;基础表&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; EMPNO &amp;gt; 0 &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; &lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: red; &quot;&gt;EXISTS&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: blue; &quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; ‘X&#39; &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; DEPT &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; DEPT.DEPTNO = EMP.DEPTNO &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; LOC = ‘MELB&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 31.5pt; text-indent: 5.25pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: teal; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;低效&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; * &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; EMP (&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;基础表&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;) &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; EMPNO &amp;gt; 0 &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; DEPTNO &lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;color: red; &quot;&gt;IN&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: purple; &quot;&gt;(SELECT&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; DEPTNO &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; DEPT &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; LOC = ‘MELB&#39;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（16）&lt;/span&gt;&lt;span style=&quot;color: green; &quot;&gt;识别&lt;/span&gt;&lt;span style=&quot;color: green; &quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color: green; &quot;&gt;低效执行&lt;/span&gt;&lt;span style=&quot;color: green; &quot;&gt;&#39;&lt;/span&gt;&lt;span style=&quot;color: green; &quot;&gt;的&lt;/span&gt;&lt;span style=&quot;color: green; &quot;&gt;SQL&lt;/span&gt;&lt;span style=&quot;color: green; &quot;&gt;语句：&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;虽然目前各种关于&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;SQL&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;优化的图形化工具层出不穷&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;但是写出自己的&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;SQL&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;工具来解决问题始终是一个最好的方法：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 47.25pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: purple; &quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; EXECUTIONS , DISK_READS, BUFFER_GETS,&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;((BUFFER_GETS-DISK_READS)/BUFFER_GETS,2&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; Hit_radio,&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;ROUND&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;(DISK_READS/EXECUTIONS,2) Reads_per_run,&lt;br /&gt;SQL_TEXT&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; V$SQLAREA&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; EXECUTIONS&amp;gt;0&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; BUFFER_GETS &amp;gt; 0&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;AND&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt; (BUFFER_GETS-DISK_READS)/BUFFER_GETS &amp;lt; 0.8&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;ORDER BY &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;4 &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;DESC&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（17） &lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;用索引提高效率：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;索引是表的一个概念部分&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;用来提高检索数据的效率，&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;ORACLE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;使用了一个复杂的自平衡&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;B-tree&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;结构&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;通常&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;通过索引查询数据比全表扫描要快&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;当&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;ORACLE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;找出执行查询和&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;Update&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;语句的最佳路径时&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, ORACLE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;优化器将使用索引&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;同样在联结多个表时使用索引也可以提高效率&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;另一个使用索引的好处是&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;它提供了主键&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;(primary key)&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;的唯一性验证&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;。那些&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;LONG&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;或&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;LONG RAW&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;数据类型&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;你可以索引几乎所有的列&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;通常&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;在大型表中使用索引特别有效&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;当然&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;你也会发现&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;在扫描小表时&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;使用索引同样能提高效率&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;虽然使用索引能得到查询效率的提高&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;但是我们也必须注意到它的代价&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;索引需要空间来存储&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;也需要定期维护&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;每当有记录在表中增减或索引列被修改时&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;索引本身也会被修改&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;这意味着每条记录的&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;INSERT , DELETE , UPDATE&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;将为此多付出&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;4 , 5 &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;次的磁盘&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;I/O . &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;因为索引需要额外的存储空间和处理&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;那些不必要的索引反而会使查询反应时间变慢&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;。定期的重构索引是有必要的&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; text-indent: 36.75pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: purple; &quot;&gt;ALTER&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;INDEX&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; &lt;indexname&gt; &lt;/indexname&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;REBUILD&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; &lt;tablespacename&gt;&lt;/tablespacename&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（18）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;用&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;EXISTS&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;替换&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;DISTINCT&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 21pt; text-indent: 21pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;当提交一个包含一对多表信息&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;比如部门表和雇员表&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;的查询时&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;避免在&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子句中使用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;DISTINCT. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;一般可以考虑用&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;EXIST&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;替换&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;, EXISTS &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;使查询更为迅速&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;因为&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;RDBMS&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;核心模块将在&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;子查询的条件一旦满足后&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;立刻返回结果&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;. &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;例子：&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;       &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;低效&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;): &lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;DISTINCT&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; DEPT_NO,DEPT_NAME &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; DEPT D , EMP E&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; margin-left: 31.5pt; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;span style=&quot;color: purple; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; D.DEPT_NO = E.DEPT_NO&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;高效&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;):&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;SELECT&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; DEPT_NO,DEPT_NAME &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; DEPT D &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;EXISTS ( SELECT&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; ‘X&#39;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;FROM&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; EMP E &lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;WHERE&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt; E.DEPT_NO = D.DEPT_NO&lt;/span&gt;&lt;span style=&quot;color: purple; &quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: rgb(255, 102, 0); &quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（19）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;sql&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;语句用大写的&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;；因为&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;oracle&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;总是先解析&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;sql&lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;语句，把小写的字母转换成大写的再执行&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;strong&gt;&lt;span&gt;（20）&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color: teal; &quot;&gt;在&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;java&lt;/span&gt;&lt;span style=&quot;color: teal; &quot;&gt;代码中尽量少用连接符“＋”连接字符串&lt;/span&gt;！&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;source: &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial; font-size: 14px; line-height: 26px; &quot;&gt;&lt;span style=&quot;font-family: &#39;courier new&#39;, courier; font-size: 13px; &quot;&gt;&lt;a href=&quot;http://blog.csdn.net/dongdongsdo0310/article/details/6729698&quot;&gt;http://blog.csdn.net/dongdongsdo0310/article/details/6729698&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/1341264668714141796/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/1341264668714141796' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/1341264668714141796'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/1341264668714141796'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/08/oracle.html' title='oracle查询效率积累'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-1179801747686250619</id><published>2011-07-10T20:31:00.000-07:00</published><updated>2011-07-10T20:33:00.518-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>Beginning with Digital Signatures in .NET Framework</title><content type='html'>&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, verdana, sans-serif; font-size: medium; &quot;&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;This article explains how to get started with digital signatures, using X509 certificates in .NET. &lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;The purpose of digital signatures is to identify data in a way that cannot easily be faked.  Phishing, infected software and illegal contents published by unknown subjects can be prevented with digital signatures. Digital signatures will allow data and digital documents to be used as if they were signed paper. Browsers are now able to recognize X.509 certificates and know which Certificate Authorities are trusted. The X.509 system has grown to be the standard format for public key certificates, and is therefore the best way of proving that a document comes from the source it claims to come from.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;This article will introduce X509 certificates, explain a little about the asymmetric cryptography that is at their heart, and end by describing how to use and manage these certificates within the .NET Framework classes.&lt;/p&gt;&lt;h2 style=&quot;font-size: 21px; margin-left: 0px; font-family: &#39;Times New Roman&#39;, Times, serif; &quot;&gt;Asymmetric Cryptography and Digital Signatures&lt;/h2&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;Digital signatures are created using asymmetric cryptography, the approach on which digital signatures are based. Asymmetric Cryptography is distinguished by having two different keys, a private key to encrypt messages and a public key to decrypt them. The cryptographic private key K&lt;sub&gt;0&lt;/sub&gt; (a suitable array of bytes) is used with an appropriate algorithm to  transform the initial human-readable message into a different message that is encrypted.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;A second public cryptographic key K&lt;sub&gt;1&lt;/sub&gt;, which is related to the private one, is used to change the encrypted message back to its original decrypted form via a second related algorithm.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;With this mechanism, your recipient is sure that the message that she/he received is your message, because only you hold the private key that is related to the public, shared, key. You digitally ‘sign’ your message.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;In practice, you will hash the message beforehand (with hash algorithm such as MD5 or SHA1), obtaining the hashed message M&lt;sub&gt;1&lt;/sub&gt;. Then you will encrypt M1 with your private key K&lt;sub&gt;0&lt;/sub&gt;, digitally signing your message, and, finally, you will send your message M, the encrypted hash M&lt;sub&gt;1&lt;/sub&gt; (the signature) and the public key K&lt;sub&gt;1&lt;/sub&gt; to your recipient. Your recipient will compute the hash of your message M and will compare it with the decrypted value of M&lt;sub&gt;1&lt;/sub&gt;. If the two hashes matches, the signature is valid.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt; You will notice that the signature is obtained by encrypting the hash of a message, rather than  the message itself. This is done for performance reasons.  Asymmetric cryptography is a slow process and the time required to encrypt, or decrypt, a message is directly related to the message length.  You can make better use of the processor by reducing the amount of data to be processed. Sometimes, a very large (in bytes) message, can be reduced, by hashing it, to a much smaller hashed message. It is more convenient to transmit a the bulk of the data as clear text and just attach less than a hundred encrypted bytes attached to it than to encrypt the entire message and send it in the encrypted form.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;Asymmetric key encryption by itself is not enough because it is necessary to trust the public key received. An attacker can deceive you by signing a message with his private key and send you a digitally confirmed message with its (related) public key, whilst  pretending he is someone  else.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;The public-key infrastructure (PKI) avoids this by utilizing a third-party entity, called Certification Authority that, under its responsibility, binds a public key to its owner. The binding occurs when the Certification Authority digitally sign a message that contains the public key and the identity of its owner. A digital certificate is obtained.&lt;/p&gt;&lt;h2 style=&quot;font-size: 21px; margin-left: 0px; font-family: &#39;Times New Roman&#39;, Times, serif; &quot;&gt;The X509 Standard for Digital Certificate&lt;/h2&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;Today, the standard  that has been adopted for digital certificate format is the X509 standard. Over the years since X.509 was developed in 1988, the initial X509 certificate format has evolved beyond the simple purpose of associating the identity of the subject with the public key, since it allows extended information to be held. The current certificate format is X509 v3 format, defined on RFC 5280. The most important information fields  that it holds  and stores is&lt;/p&gt;&lt;ul&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;b&gt;Issuer:&lt;/b&gt;&lt;span&gt; The identity of the certification authority that signed the certificate, validating it. It is expressed in ITU-T X.501 Distinguished Name format.&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;b&gt;Validity:&lt;/b&gt;&lt;span&gt; it defines the dates between which the certificate can be used.&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;b&gt;Subject:&lt;/b&gt;&lt;span&gt; it defines the identity of the public key owner. It is expressed as ITU-T X.501 Distinguished Name format.&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;b&gt;SubjectPublicKeyInfo:&lt;/b&gt;&lt;span&gt; it contains an encoded version of the public key.&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;b&gt;X509 v3 extensions:&lt;/b&gt;&lt;span&gt;  it defines a set of extensions that establishes the purpose of the certificate and set some properties related to its management. Each extension can be critical (e.g. cannot be ignored) or not.&lt;br /&gt;&lt;br /&gt;Among the X509 v3 extensions,  the two most important are&lt;/span&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;/p&gt;&lt;ul&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;b&gt;Key Usage:&lt;/b&gt;&lt;span&gt; it defines the usage allowed for the private key, for example &lt;b&gt;digitalSignature&lt;/b&gt; (allow the digital signature), &lt;b&gt;keyCertSign&lt;/b&gt; (allow the signature of certificates by a certification authority), &lt;b&gt;keyAgreement&lt;/b&gt; (allow the key exchange on protocol such as TLS/SSL).&lt;/span&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;b&gt;Extended Key Usage:&lt;/b&gt;&lt;span&gt;  it defines extended properties in relation to the usage of the private key. For example Server Authentication (for TLS/SSL certificate), Code Signing (for authenticode signature), Email Protection (for protocol such as S/MIME).&lt;/span&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;You can view the certificates installed on a Windows® machine by using  &lt;i&gt;certmgr.msc&lt;/i&gt;&lt;/p&gt;&lt;p class=&quot;ILLUSTRATION&quot; style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: left; margin-bottom: 0px; float: left; margin-right: 20px; &quot;&gt; &lt;img src=&quot;http://www.simple-talk.com/iwritefor/articlefiles/833-Digita2.jpg&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;In the details tab, you can see the binding between the subject identity (Subject field) and the Public Key (Public Key field). This is highlighted to show its content. It consists of a sequence of bytes in hexadecimal form.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;An important feature of the X509 standard is the assignment of a unique identifier to each entity inside a X509 certificate which is in the form of a sequence of numbers organized hierarchically; For example, the sequence 1.3.6.1.5.5.7.3.1 identifies the Server Authentication extended-key usage. Those sequences, called OIDs (object identifiers) are assigned by the authorized organization (IANA, ISO and ITU-T).&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;The most commonly used Certificate file format today is the PKCS#12 (personal information exchange standard) format. This standard permits you to prepare a X509 certificate file that may contain the private key as well, encrypted with a secret password. This is easiest imagined as a bag that contains the X509 certificate and the encrypted private key.&lt;/p&gt;&lt;h2 style=&quot;font-size: 21px; margin-left: 0px; font-family: &#39;Times New Roman&#39;, Times, serif; clear: both; &quot;&gt;Manage X509 Certificates Stores with .NET Framework&lt;/h2&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;The .NET classes involved on the X509 certificate management are those under the &lt;b&gt;System.Security.Cryptography.X509Certificates&lt;/b&gt; namespace.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;Before it can be used, a digital certificate must be located and loaded. X509 certificates are stored on Microsoft® Windows machines in a container that can be browsed with certmgr.msc command. Launching the command,  you will see something like this:&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;img src=&quot;http://www.simple-talk.com/iwritefor/articlefiles/833-Digita1.jpg&quot; border=&quot;0&quot; /&gt;&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;This shows the so called “current user” certificate container, the container associated with the user currently logged on the machine. The “Personal” subfolder contains one certificate with a ‘friendly name’ given by webmail.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;X509 certificates can be stored on a ‘per machine’ basis too. To open the certificate container for a local or remote machine, run mmc.exe and add the certificates snap-in, selecting the computer you want to administer.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;Within the .NET Framework base classes, a subfolder is called “store”. A certificates store can be opened utilizing the &lt;span style=&quot;color: windowtext; line-height: 18px; font-family: Arial, sans-serif; &quot;&gt;X509Store&lt;/span&gt;&lt;span&gt; class:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;X509Store&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt; store = &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;X509Store(&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;StoreName&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;.My, &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;StoreLocation&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;.CurrentUser);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;store.Open(&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;OpenFlags&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;.OpenExistingOnly);&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;In this example, the “current user” container is opened and the certificates that reside on the “Personal” store are loaded.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;To open a store on the “local machine” container, you must change the &lt;b&gt;StoreLocation&lt;/b&gt; enumeration value with the value:&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;StoreLocation&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;.LocalMachine&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;The store that you wish to open is set with the StoreName enumeration. Others enumeration values allow you to select other stores inside the container. These are stores related to the X509 certificates that are issued to other entities involved in the PKI system. Those are beyond the scope of this article.&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;span style=&quot;color: windowtext; &quot;&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;Notice now the Open method. This accepts, as an input parameter, an &lt;b&gt;OpenFlags&lt;/b&gt; enumeration value given by &lt;b&gt;OpenExistingOnly&lt;/b&gt;. This states that the Open method can only open an existing store inside the container. It might seem to imply to you that stores can be created too. And you’d be right.  Using the appropriate override of the&lt;b&gt;X509Store&lt;/b&gt; class constructor, a new store can be created:&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;X509Store&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt; store = &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;X509Store&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;(“MyStore”, &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;StoreLocation&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;.CurrentUser);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;store.Open(&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;OpenFlags&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;.ReadWrite);&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;In this example, a new store named “MyStore” is created and opened for read write operations.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;Notice that, if a new store is created, the .NET Framework doesn’t allow you to remove it anymore. There is no method that permits a store deletion. It can be deleted only with another tool such as CAPICOM or by using Microsoft® CryptoAPI directly.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;It’s time now to work with certificates on the stores. To do so, the X509Store class provides a Certificates property of type &lt;b&gt;X509Certificate2Collection&lt;/b&gt;:&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;X509Certificate2Collection&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt; certificates = store.Certificates;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;The certificates object now contains all the certificates stored on the opened store. A certificate can be retrieved from the collection with the following code:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;X509Certificate2 &lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;certificate = certificates[n];&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;with n being the selected index.&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;A certificate can also be loaded from a certificate file:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;X509Certificate2 &lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;myCertificate = &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;X509Certificate2&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;(“c:\....\mycertificate.pfx”);&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;and then saved into the opened store:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;store.Add(myCertificate);&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;Finally, a certificate can be removed from a store with the method:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;store.Remove(certificates[n]);&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;h2 style=&quot;font-size: 21px; margin-left: 0px; font-family: &#39;Times New Roman&#39;, Times, serif; &quot;&gt;Manage X509 Certificates with .NET Framework&lt;/h2&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;The &lt;b&gt;X509Certificate2&lt;/b&gt; class allows you to manage the “certificate data units” programmatically. First of all, notice the suffix 2 on the class name. This happens because the &lt;b&gt;X509Certificate2&lt;/b&gt; class extends methods and properties of its base class, the &lt;b&gt;X509Certificate&lt;/b&gt; class. It extends the &lt;b&gt;X509Certificate&lt;/b&gt; class by allowing, above all, the management of the private key (if  present, as seen for the PKCS#12 certificate format), and the browsing of the X509 v3 extensions.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;The &lt;b&gt;X509Certificate2&lt;/b&gt; class allows you to retrieve, from the certificate that is loaded, its representative data through a set of properties. Among them:&lt;/p&gt;&lt;table class=&quot;MsoTableGrid&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;618&quot; border=&quot;0&quot; style=&quot;margin-left: 20px; border-right-width: medium; border-right-style: none; border-right-color: initial; border-top-width: medium; border-top-style: none; border-top-color: initial; border-left-width: medium; border-left-style: none; border-left-color: initial; border-bottom-width: medium; border-bottom-style: none; border-bottom-color: initial; border-collapse: collapse; &quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th valign=&quot;baseline&quot; bordercolor=&quot;silver&quot; width=&quot;91&quot; bgcolor=&quot;#f5f5f5&quot; height=&quot;29&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 68.1pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;b&gt;&lt;span&gt;Name&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/th&gt;&lt;th valign=&quot;baseline&quot; bordercolor=&quot;silver&quot; width=&quot;143&quot; bgcolor=&quot;#f5f5f5&quot; height=&quot;29&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 107.4pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;b&gt;&lt;span&gt;Type&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/th&gt;&lt;th valign=&quot;baseline&quot; bordercolor=&quot;silver&quot; bgcolor=&quot;#f5f5f5&quot; height=&quot;29&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 342px; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;b&gt;&lt;span&gt;Description&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;91&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 68.1pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;Issuer&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;143&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 107.4pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;b&gt;&lt;span&gt;string&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 342px; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;Identify the issuer of the certificate (the certification authority that signed the certificate).&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;91&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 68.1pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;Subject&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;143&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 107.4pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;b&gt;&lt;span&gt;string&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 342px; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;Identify the  subject, owner of the private key.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;91&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 68.1pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;NotBefore&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;143&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 107.4pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;b&gt;&lt;span&gt;DateTime&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 342px; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;It states that the certificate can be used only after the NotBefore data.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;91&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 68.1pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;NotAfter&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;143&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 107.4pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;b&gt;&lt;span&gt;DateTime&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 342px; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;It states that the certificate can be used  until the NotAfter data.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;91&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 68.1pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;PublicKey&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;143&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 107.4pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;b&gt;&lt;span&gt;PublicKey&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 342px; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;Represents the Public Key associated to the subject.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;91&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 68.1pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;Extensions&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; width=&quot;143&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 107.4pt; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;b&gt;&lt;span&gt;X509ExtensionCollection&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;/td&gt;&lt;td bordercolor=&quot;silver&quot; style=&quot;padding-right: 5.4pt; padding-left: 5.4pt; padding-bottom: 0in; width: 342px; padding-top: 0in; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; align=&quot;left&quot; style=&quot;font-size: 12px; margin-left: 0in; font-family: Arial, Helvetica, sans-serif; text-align: left; &quot;&gt;&lt;span&gt;Collection of X509 v3 extensions.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;In those, the public key is retrieved as a &lt;b&gt;PublicKey&lt;/b&gt; object. This object contains all the information related to the public key itself, but this information are  not easy to explain in this article because the reader would require a knowledge of asymmetric cryptographic algorithms, ASN.1 encoding rules and OID assignment.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;You can however get a string representation of the public hey by utilizing a &lt;b&gt;X509Certificate&lt;/b&gt; class method, from which &lt;b&gt;X509CertificateClass2&lt;/b&gt; derives:&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt; publicKey = certificate.GetPublicKeyString();&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;The publicKey string now contains the same string representation of the public key seen on the first image proposed on this article (without white spaces).&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;The X509 v3 Extensions can be analyzed through browsing on the collection elements. Those are of type X509Extension. This type defines the OID assigned to the related extension and its ASN.1 encoded value.&lt;/p&gt;&lt;h2 style=&quot;font-size: 21px; margin-left: 0px; font-family: &#39;Times New Roman&#39;, Times, serif; &quot;&gt;Performing Signatures with the .NET Framework&lt;/h2&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;To perform a signature using an X509 certificate and .NET Framework base classes, the X509 certificate must have the private key too. In fact, as stated previously, a signature consists of an encryption with the private key (that must be present) of hashes computed on messages to sign.  If an object of type X509Certificate2 has the private key (due to the fact that the PKCS#12 file imported on the store has the private key). This can be retrieved with the following code:&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;AsymmetricAlgorithm&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt; privateKey = certificate.PrivateKey;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;You&#39;ll have noticed the type of &lt;b&gt;PrivateKey&lt;/b&gt; property.  It is of type  &lt;b&gt;AsymmetricAlgorithm&lt;/b&gt;, a class that can be found under the &lt;b&gt;System.Security.Cryptography&lt;/b&gt; namespace. Is seems to have nothing to do with private keys. But remember that t&lt;span&gt;he private key is an element, inside the PKI elements, that require an high level of protection. When importing a PKCS#12 file into your X509 store, the private key became a more complex “object” inside the store, in the sense that it is saved  “keeping in mind the purpose of the same and its protection requirements”. It need an unique identifier to search for it, it need protection against attacker, it need access control, it need a suitable, but flexible, storage. Without  entering more deeply on the argument, think of this object as  a sort of “pipeline” between your code and the cryptographic subsystem of your operating system that manages, in a secure way, all the cryptographic operation based on your key pairs.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;In reality, the &lt;b&gt;AsymmetricAlgorithm&lt;/b&gt; class is only a base class of more complex classes. It is the base class for all the classes that implement specific asymmetric algorithms standards. Today, a widely-adopted standard for digital signature is RSA asymmetric encryption with SHA-1 hash algorithm. If the certificate contains RSA asymmetric keys pairs, the previous method does not, as one might expect, return an &lt;b&gt;AsymmetricAlgorithm&lt;/b&gt; &lt;span&gt;object, &lt;/span&gt;&lt;span&gt;but an &lt;b&gt;RSACryptoServiceProvider&lt;/b&gt; object, whose class derives from the &lt;b&gt;AsymmetricAlgorithm&lt;/b&gt; class. The &lt;b&gt;RSACryptoServiceProvider&lt;/b&gt; &lt;/span&gt;&lt;span&gt;class contains all the properties and methods&lt;/span&gt;&lt;span&gt; that are related to what we said previously.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;So, the next step is to cast the &lt;b&gt;privateKey&lt;/b&gt; object to a &lt;b&gt;RSACryptoServiceProvider&lt;/b&gt; object, or, in more elegant way:&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;RSACryptoServiceProvider&lt;/span&gt;&lt;span&gt; privateKey&lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;                          &lt;/span&gt;&lt;span&gt;=  certificate.PrivateKey &lt;span style=&quot;color: blue; &quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;RSACryptoServiceProvider&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;Now a signature can be performed. To do so, the &lt;b&gt;SignDat&lt;/b&gt;a method of the &lt;b&gt;privateKey&lt;/b&gt; object can be used. It accepts, as input, (1) the data to sign, as array of bytes, and (2) the object that represents the hash algorithm to use:&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;[] buffer = &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;Encoding&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;.Default.GetBytes(&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21); &quot;&gt;&quot;Hello World ... !&quot;&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;byte&lt;/span&gt;&lt;span&gt;[] signature = privateKey.SignData(buffer, &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;new&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;SHA1Managed&lt;/span&gt;&lt;span&gt;());&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;The signature can also be verified. To do so you must utilize the public key of the certificate.&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;RSACryptoServiceProvider&lt;/span&gt;&lt;span&gt; publicKey&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;                        &lt;/span&gt;&lt;span&gt;=  certificate.PublicKey.Key &lt;span style=&quot;color: blue; &quot;&gt;as&lt;/span&gt; &lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;RSACryptoServiceProvider&lt;/span&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt; &lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;bool&lt;/span&gt;&lt;span&gt; verify = publicKey.VerifyData&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;                       &lt;/span&gt;&lt;span&gt; (buffer, &lt;span style=&quot;color: blue; &quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;SHA1Managed&lt;/span&gt;(), signature);&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;From the above example you see that the &lt;b&gt;certificate.PublicKey.Key&lt;/b&gt; property is again an object of type &lt;b&gt;AsymmetricAlgortihm&lt;/b&gt;. This is for the same reasons seen for the private key.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;The certificate to use for the verification can be the same certificate used for the generation of the signature but even a version of it that contains only the public key. No private key is required. And this is what always happens. Remember that the recipient receive only the signed message plus the certificate without the private key, that remain secret and accessible only by its owner. This means that verifications occurs always with the utilization of the public key “extracted” from a certificate that doesn’t have private key.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;Another way to perform signature is to use the class &lt;b&gt;RSAPKCS1SignatureFormatter&lt;/b&gt;. It brings to the same result of the previous method. To do so, the hash of data to sign must be computed first:&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;[] buffer = &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;Encoding&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;.Default.GetBytes(&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21); &quot;&gt;&quot;Hello World ... !&quot;&lt;/span&gt;&lt;span style=&quot;color: windowtext; &quot;&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;byte&lt;/span&gt;&lt;span&gt;[] hash = &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;SHA1Managed&lt;/span&gt;&lt;span&gt;.Create().ComputeHash(buffer);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;RSAPKCS1SignatureFormatter&lt;/span&gt;&lt;span&gt; formatter&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span&gt;                    = &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;new&lt;/span&gt;&lt;span&gt;  &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;RSAPKCS1SignatureFormatter&lt;/span&gt;&lt;span&gt;(certificate.PrivateKey);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span&gt;formatter.SetHashAlgorithm(&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21); &quot;&gt;&quot;SHA1&quot;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span&gt;signature = formatter.CreateSignature(hash);&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;To verify the signature, use the &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); font-family: Arial, sans-serif; &quot;&gt;RSAPKCS1SignatureDeformatter&lt;/span&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt; class:&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;listing&quot; style=&quot;border-right-color: rgb(202, 202, 202); border-right-width: 1px; border-right-style: solid; padding-right: 10px; border-top-color: rgb(202, 202, 202); border-top-width: 1px; border-top-style: solid; padding-left: 10px; font-weight: normal; font-size: 11px; padding-bottom: 10px; margin-left: 20px; border-left-color: rgb(202, 202, 202); border-left-width: 1px; border-left-style: solid; padding-top: 10px; border-bottom-color: rgb(202, 202, 202); border-bottom-width: 1px; border-bottom-style: solid; font-family: &#39;Courier New&#39;, Courier, monospace; background-color: rgb(242, 242, 242); text-align: left; &quot;&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;RSAPKCS1SignatureDeformatter&lt;/span&gt;&lt;span&gt; deformatter&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span&gt;                    = &lt;/span&gt;&lt;span style=&quot;color: blue; &quot;&gt;new&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span style=&quot;color: rgb(43, 145, 175); &quot;&gt;RSAPKCS1SignatureFormatter&lt;/span&gt;&lt;span&gt;(certificate.PublicKey.Key);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span&gt;deformatter.SetHashAlgorithm(&lt;/span&gt;&lt;span style=&quot;color: rgb(163, 21, 21); &quot;&gt;&quot;SHA1&quot;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 0px; font-family: Arial, Helvetica, sans-serif; text-align: justify; margin-left: 20px; &quot;&gt;&lt;span style=&quot;color: blue; &quot;&gt;bool&lt;/span&gt;&lt;span&gt; verify = formatter.VerifySignature(hash,signature);&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;/p&gt;&lt;h2 style=&quot;font-size: 21px; margin-left: 0px; font-family: &#39;Times New Roman&#39;, Times, serif; &quot;&gt;Conclusion&lt;/h2&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;This article gave an outline of what a digital signature is, and how to digitally sign data with the .NET Framework. Digital signatures, and cryptographic services in general, are very complex subjects and  are not easy to summarize. If you feel we haven&#39;t really helped to make it clearer for you, please say so by leaving a comment to this article and even ask the author for other articles on the subject, indicating what you would like to read more about.&lt;/p&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;If you would like to experiment digital signatures with X509 certificate, probably you need some X509 certificate for testing. We end this paper by providing you some way to gets digital certificates:&lt;/p&gt;&lt;ul&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;You can download the openssl projects files at &lt;a href=&quot;http://www.openssl.org/&quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;The OpenSSL Project&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;and set up a smart certification authority.&lt;/span&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;You can use makecert.exe command  (see &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bfsktky3(VS.80).aspx&quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;Certificate Creation Tool (Makecert.exe) &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;) that you can find on Microsoft® Windows SDK.&lt;/span&gt;&lt;p style=&quot;font-size: 12px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;&lt;/p&gt;&lt;/li&gt;&lt;li style=&quot;margin-top: 0px; font-size: 12px; margin-bottom: 3px; margin-left: 20px; font-family: Arial, Helvetica, sans-serif; text-align: justify; &quot;&gt;You can generate X509 certificate on-line using X509 Builder web application at the author’s site  &lt;a href=&quot;http://www.we-coffee.com/x509Builder.aspx&quot;&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;wecoffee&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Arial, sans-serif; &quot;&gt;.&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;source: &lt;a href=&quot;http://www.simple-talk.com/content/print.aspx?article=833&quot;&gt;http://www.simple-talk.com/content/print.aspx?article=833&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/1179801747686250619/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/1179801747686250619' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/1179801747686250619'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/1179801747686250619'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/07/beginning-with-digital-signatures-in.html' title='Beginning with Digital Signatures in .NET Framework'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-6673446710590619530</id><published>2011-07-07T21:40:00.000-07:00</published><updated>2011-07-08T01:35:53.636-07:00</updated><title type='text'>x509,pkcs7和Pkcs12之間關係</title><content type='html'>&lt;div&gt;&lt;br /&gt;x.509,是x500那套網絡協議（好像是目錄協議吧）的一個子集，專門定義了在目錄訪問中需要身份認證的證書的格式。後來被rfc收錄3280。 &lt;/div&gt;&lt;div&gt;&lt;br /&gt;PKCS#12是“個人信息交換語法”。它可以用來將x.509的證書和證書對應的私鑰打包，進行交換。比如你在windows下，可以將IE裡的證書連帶私鑰導出，並設置一個口令保護。這個pfx格式的文件，就是按照pkcs#12的格式打包的。當然pkcs#12不僅僅只是作以上用途的。它可以用來打包交換任何信息。你可以和張三李四用PKCS#12來交換私人數據，包括x.509證書和私鑰。&lt;br /&gt;你在交換x.509證書和私鑰可以採用任何數據格式，例如PKCS#12。 &lt;/div&gt;&lt;div&gt;&lt;br /&gt;PKCS#7麼，舉個例子，你給張三李四發了一封籤名郵件，同時你將你的個人證書隨郵件一起發給了張三李四，這個時候，你可以按照PKCS#7的格式來打包。&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif; &quot;&gt;&lt;span title=&quot;&quot; style=&quot;background-color: rgb(230, 236, 249); color: rgb(0, 0, 0); &quot;&gt;P7一般是把證書分成兩個文件，一個公鑰一個私鑰，有PEM和DER兩種編碼方式。&lt;/span&gt;&lt;span title=&quot;&quot;&gt;PEM比較多見，就是純文本的，P7一般是分發公鑰用，看到的就是一串可見字符串，擴展名經常是.crt,.cer,.key等。 &lt;/span&gt;&lt;span title=&quot;&quot;&gt;DER是二進制編碼。&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;P12是把證書壓成一個文件，.pfx 。&lt;/span&gt;&lt;span title=&quot;&quot;&gt;主要是考慮分發證書，私鑰是要絕對保密的，不能隨便以文本方式散播。&lt;/span&gt;&lt;span title=&quot;&quot;&gt;所以P7格式不適合分發。 &lt;/span&gt;&lt;span title=&quot;&quot;&gt;.pfx中可以加密碼保護，所以相對安全些。&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;在實踐中要中，用戶證書都是放在USB Key中分發，服務器證書經常還是以文件方式分發。&lt;/span&gt;&lt;span title=&quot;&quot;&gt;服務器證書和用戶證書，都是X509證書，就是裡面的屬性有區別.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;X509 是證書規範&lt;br /&gt;PKCS#7 是消息語法（常用於數字簽名與加密）&lt;br /&gt;PKCS#12 個人消息交換與打包語法（如.PFX .P12）打包成帶公鑰與私鑰&lt;br /&gt;還有其它常用的是PKCS#10 是證書請求語法。&lt;br /&gt;&lt;br /&gt;通過CA產生的出來的證書格式文件一般是以PFX P12格式發布給使用者（公鑰與私鑰），用戶拿到證書後，&lt;br /&gt;可以通過IE來導入或直接雙擊嚮導安裝證書，此時私鑰安裝到系統的私有密鑰庫中。使用時系統會自動查找到&lt;br /&gt;私鑰。而最安全的方式還是使用其它USB硬件來存儲，私鑰將無法再從硬件鎖只導出，並且支持硬件訪問需要&lt;br /&gt;用戶的密鑰才能訪問到硬件內的私鑰，永遠保證了私鑰不出硬件鎖！提高了安全性，靈活性，且可以移動的方便性。如ETOKEN產品，一些硬件信息可參考www.dztech.cn.&lt;br /&gt;而相互雙方通迅時使用且​​交換的是帶公鑰的證書如CER文件。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PKI標準可以分為第一代和第二代標準[12]。&lt;br /&gt;&lt;br /&gt;第一代PKI標準主要包括美國RSA公司的公鑰加密標準（Public Key Cryptography Standards，PKCS）系列、國際電信聯盟的ITU-T X.509、IETF組織的公鑰基礎設施X.509（Public Key Infrastructure X .509，PKIX）標準系列、無線應用協議（Wireless Application Protocol ,WAP）論壇的無線公鑰基礎設施（Wireless Public Key Infrastructure，WPKI）標準等。第一代PKI標準主要是基於抽象語法符號（Abstract Syntax Notation One，ASN.1）編碼的，實現比較困難，這也在一定程度上影響了標準的推廣。&lt;br /&gt;第二代PKI標準是在2001年，由微軟、VeriSign和webMethods三家公司發布了XML密鑰管理規範（XML Key Management Specification，XKMS），被稱為第二代PKI標準。 XKMS由兩部分組成：XML密鑰信息服務規範（XML Key Information Service Specification，X-KISS）和XML密鑰註冊服務規範（XML Key Registration Service Specification，X-KRSS）。 X-KISS定義了包含在XML-SIG元素中的用於驗證公鑰信息合法性的信任服務規範；使用X-KISS規範，XML應用程序可通過網絡委託可信的第三方CA處理有關認證簽名、查詢、驗證、綁定公鑰信息等服務。 X-KRSS則定義了一種可通過網絡接受公鑰註冊、撤銷、恢復的服務規範；XML應用程序建立的密鑰對，可通過X-KRSS規範將公鑰部分及其它有關的身份信息發給可信的第三方CA註冊。 X-KISS和X-KRSS規範都按照XML Schema 結構化語言定義，使用簡單對象訪問協議（SOAP V1.1）進行通信，其服務與消息的語法定義遵循Web服務定義語言（WSDL V1.0）。目前XKMS已成為W3C的推薦標準，並已被微軟、VeriSign等公司集成於他們的產品中（微軟已在ASP.net中集成了XKMS，VeriSign已發布了基於Java的信任服務集成工具包TSIK）。&lt;br /&gt;CA中心普遍採用的規範是X.509[13]系列和PKCS系列，其中主要應用到了以下規範：&lt;br /&gt;1． X.209（1988）&lt;br /&gt;ASN.1是描述在網絡上傳輸信息格式的標準方法。它有兩部分：第一部份（ISO 8824/ITU X.208）描述信息內的數據、數據類型及序列格式，也就是數據的語法；第二部分（ISO 8825/ITU X.209）描述如何將各部分數據組成消息，也就是數據的基本編碼規則。&lt;br /&gt;ASN.1原來是作為X.409的一部分而開發的，後來才獨立地成為一個標準。這兩個協議除了在PKI體系中被應用外，還被廣泛應用於通信和計算機的其他領域。&lt;br /&gt;2． X.500（1993）&lt;br /&gt;X.500是一套已經被國際標準化組織（ISO）接受的目錄服務系統標準，它定義了一個機構如何在全局範圍內共享其名字和與之相關的對象。 X.500是層次性的，其中的管理域（機構、分支、部門和工作組）可以提供這些域內的用戶和資源信息。在PKI體系中，X.500被用來惟一標識一個實體，該實體可以是機構、組織、個人或一台服務器。 X.500被認為是實現目錄服務的最佳途徑，但X.​​500的實現需要較大的投資，並且比其他方式速度慢;而其優勢具有信息模型、多功能和開放性。&lt;br /&gt;3． X.509（1993）&lt;br /&gt;X.509是由國際電信聯盟（ITU-T）制定的數字證書標準。在X.500確保用戶名稱惟一性的基礎上，X.509為X.500用戶名稱提供了通信實體的鑑別機制，並規定了實體鑑別過程中廣泛適用的證書語法和數據接口。&lt;br /&gt;X.509的最初版本公佈於1988年。 X.509證書由用戶公共密鑰和用戶標識符組成。此外還包括版本號、證書序列號、CA標識符、簽名算法標識、簽發者名稱、證書有效期等信息。這一標準的最新版本是X.509 v3，它定義了包含擴展信息的數字證書。該版數字證書提供了一個擴展信息字段，用來提供更多的靈活性及特殊應用環境下所需的信息傳送。&lt;br /&gt;4． PKCS系列標準&lt;br /&gt;PKCS是由美國RSA數據安全公司及其合作夥伴制定的一組公鑰密碼學標準，其中包括證書申請、證書更新、證書作廢表發布、擴展證書內容以及數字簽名、數字信封的格式等方面的一系列相關協議。到1999年底，PKCS已經公佈了以下標準：&lt;br /&gt;PKCS#1：定義RSA公開密鑰算法加密和簽名機制，主要用於組織PKCS#7中所描述的數字簽名和數字信封。&lt;br /&gt;PKCS#3：定義Diffie-Hellman密鑰交換協議。&lt;br /&gt;PKCS#5：描述一種利用從口令派生出來的安全密鑰加密字符串的方法。使用MD2或MD5 從口令中派生密鑰，並採用DES-CBC模式加密。主要用於加密從一個計算機傳送到另一個計算機的私人密鑰，不能用於加密消息。&lt;br /&gt;PKCS#6：描述了公鑰證書的標準語法，主要描述X.509證書的擴展格式。&lt;br /&gt;PKCS#7：定義一種通用的消息語法，包括數字簽名和加密等用於增強的加密機制，PKCS#7與PEM兼容，所以不需其他密碼操作，就可以將加密的消息轉換成PEM消息。&lt;br /&gt;PKCS#8：描述私有密鑰信息格式，該信息包括公開密鑰算法的私有密鑰以及可選的屬性集等。&lt;br /&gt;PKCS#9：定義一些用於PKCS#6證書擴展、PKCS#7數字簽名和PKCS#8私鑰加密信息的屬性類型。&lt;br /&gt;PKCS#10：描述證書請求語法。&lt;br /&gt;PKCS#11：稱為Cyptoki，定義了一套獨立於技術的程序設計接口，用於智能卡和PCMCIA卡之類的加密設備。&lt;br /&gt;PKCS#12：描述個人信息交換語法標準。描述了將用戶公鑰、私鑰、證書和其他相關信息打包的語法。&lt;br /&gt;PKCS#13：橢圓曲線密碼體制標準。&lt;br /&gt;PKCS#14：偽隨機數生成標準。&lt;br /&gt;PKCS#15：密碼令牌信息格式標準。&lt;br /&gt;5． OCSP在線證書狀態協議&lt;br /&gt;OCSP（Online Certificate Status Protocol）[14]是IETF頒布的用於檢查數字證書在某一交易時刻是否仍然有效的標準。該標準提供給PKI用戶一條方便快捷的數字證書狀態查詢通道，使PKI體系能夠更有效、更安全地在各個領域中被廣泛應用。&lt;br /&gt;6． LDAP 輕量級目錄訪問協議&lt;br /&gt;LDAP規範（RFC1487）簡化了笨重的X.500目錄訪問協議，並且在功能性、數據表示、編碼和傳輸方面都進行了相應的修改。 1997年，LDAP第3版本成為互聯網標準。目前，LDAP v3已經在PKI體系中被廣泛應用於證書信息發布、CRL信息發布、CA政策以及與信息發布相關的各個方面。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;source: &lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://topic.csdn.net/u/20071015/18/37a2bffb-2354-493e-b5a9-b96ab28063ae.html&quot;&gt;http://topic.csdn.net/u/20071015/18/37a2bffb-2354-493e-b5a9-b96ab28063ae.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://hi.baidu.com/twmp/blog/item/661e9e3fa78764c97d1e71d1.html&quot;&gt;http://hi.baidu.com/twmp/blog/item/661e9e3fa78764c97d1e71d1.html&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/6673446710590619530/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/6673446710590619530' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/6673446710590619530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/6673446710590619530'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/07/x509pkcs7pkcs12.html' title='x509,pkcs7和Pkcs12之間關係'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-5830703976652903774</id><published>2011-06-30T20:53:00.000-07:00</published><updated>2011-06-30T21:00:06.629-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>JAVA和C＃3DES加密解密</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;p style=&quot;margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span title=&quot;&quot; style=&quot;background-color: rgb(230, 236, 249); color: rgb(0, 0, 0); &quot;&gt;一個項目.net 要調用JAVA的WEB&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;SERVICE，數據採用3DES加密，涉及到兩種語言3DES一致性的問題，&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;下面分享一下，&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;這裡的KEY採用Base64編碼，便用分發，因為Java的Byte範圍為-128至127，c#的Byte範圍是0-255&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;核心是確定Mode和Padding，關於這兩個的意思可以搜索3DES算法相關文章&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;一個是C#採用CBC&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;Mode，PKCS7 Padding,Java採用CBC Mode，PKCS5Padding Padding,&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;另一個是C#採用ECB&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;Mode，PKCS7 Padding,Java採用ECB Mode，PKCS5Padding&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;Padding,&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;Java的ECB模式不需要IV&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;對字符加密時，雙方採用的都是UTF-8編碼.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span title=&quot;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;span title=&quot;&quot;&gt;&lt;span title=&quot;主要差异如下：&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;&lt;b&gt;主要差異如下： &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;1、 对于待加密解密的数据，各自的填充模式不一样&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;1、 對於待加密解密的數據，各自的填充模式不一樣&lt;br /&gt;     &lt;/span&gt;&lt;span title=&quot;C#的模式有：ANSIX923、ISO10126、None、PKCS7、Zero，而Java有：NoPadding、PKCS5Padding、SSL3Padding&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;C#的模式有：ANSIX923、ISO10126、None、PKCS7、Zero，而Java有：NoPadding、PKCS5Padding、SSL3Padding&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;2、 各自默认的3DES实现，模式和填充方式不一样&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;2、 各自默認的3DES實現，模式和填充方式不一樣&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;C#的默认模式为CBC,默认填充方式为PKCS7; java的默认模式为ECB，默认填充方式为PKCS5Padding&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;C#的默認模式為CBC,默認填充方式為PKCS7; java的默認模式為ECB，默認填充方式為PKCS5Padding&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;3、 各自的key的size不一样&quot;&gt;3、 各自的key的size不一樣&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;C#中key的size为16和24均可；java中要求key的size必须为24；对于CBC模式下的向量iv的size两者均要求必须为8&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;C#中key的size為16和24均可；java中要求key的size必須為24；對於CBC模式下的向量iv的size兩者均要求必須為8&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;翻看了3DES的原理：&quot;&gt;翻看了3DES的原理：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;DES主要采用替换和移位的方法,用56位密钥对64位二进制数据块进行加密,每次加密可对64位的输入数据进行16轮编码,&quot;&gt;DES主要採用替換和移位的方法,用56位密鑰對64位二進制數據塊進行加密,每次加密可對64位的輸入數據進行16輪編碼,&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;经一系列替换和移位后,输入的64位转换成安全不同的64的输出数据.&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;經一系列替換和移位後,輸入的64位轉換成安全不同的64的輸出數據.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;3DES:是在DES的基础上采用三重DES,即用两个56位的密钥K1,K2,发送方用K1加密,K2解密,再使用K1加密.接收方使用K1解密,K2加密,再使用&quot;&gt;3DES:是在DES的基礎上採用三重DES,即用兩個56位的密鑰K1,K2,發送方用K1加密,K2解密,再使用K1加密.接收方使用K1解密,K2加密,再使用&lt;/span&gt;&lt;span title=&quot;K1解密,&quot;&gt;K1解密,&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;其效果相当于密钥长度加倍.&quot;&gt;其效果相當於密鑰長度加倍.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;于是尝试在java中，对key进行补位，即用前8个字节作为byte[24] 中的byte[16]~byte[23];发现与c#中加密的结果相同！&quot;&gt;於是嘗試在java中，對key進行補位，即用前8個字節作為byte[24] 中的byte[16]~byte[23];發現與c#中加密的結果相同！&lt;/span&gt;&lt;span title=&quot;于是大胆假设C#中可能是检查key的size为16的时候&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;於是大膽假設C#中可能是檢查key的size為16的時候&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;自动将前8个字节作为k3进行了补位，而java没有实现这一点（因为java的3DES算法中强制要求key的size必须为24）。&quot;&gt;自動將前8個字節作為k3進行了補位，而java沒有實現這一點（因為java的3DES算法中強制要求key的size必須為24）。&lt;/span&gt;&lt;span title=&quot;这样的情况下，可能就是发送方用k1加密、k2解密、k3再加密；接受方k3解密、k2加密、再k1解密来实现。&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;這樣的情況下，可能就是發送方用k1加密、k2解密、k3再加密；接受方k3解密、k2加密、再k1解密來實現。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;最终经过编码验证，确认key大小为24时，java和c#的加密解密结果相一致。&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;最終經過編碼驗證，確認key大小為24時，java和c#的加密解密結果相一致。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;Java中实现时，只要注意对大小不足24的key进行补位，和采用CBC模式，填充模式为PKCS5Padding即可。&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;Java中實現時，只要注意對大小不足24的key進行補位，和採用CBC模式，填充模式為PKCS5Padding即可。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;还有一种让Java和.Net兼容的方式,在.Net中指定模式为ECB，填充为PKCS7,然后在Java中采用其默认的模式（DESede/ECB/PKCS5Padding）即可,注意双方约定key的size&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;還有一種讓Java和.Net兼容的方式,在.Net中指定模式為ECB，填充為PKCS7,然後在Java中採用其默認的模式（DESede/ECB/PKCS5Padding）即可,注意雙方約定key的size&lt;/span&gt;&lt;span title=&quot;为24个字节。&quot;&gt;為24個字節。&lt;/span&gt;&lt;span title=&quot;建议双方对key以base64编码字符串进行告知，因为java和.net中byte字节的范围不相同(前者-128~127,后者0~255)，避免不必要的处理。&quot; style=&quot;background-color: rgb(255, 255, 255); &quot;&gt;建議雙方對key以base64編碼字符串進行告知，因為java和.net中byte字節的範圍不相同(前者-128~127,後者0~255)，避免不必要的處理。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif; font-size: 16px; line-height: normal; &quot;&gt;&lt;span title=&quot;Click for alternate translations&quot; class=&quot;&quot;&gt;&lt;span title=&quot;Click for alternate translations&quot; class=&quot;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;b&gt;下面是C#代码&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;line-height: 25px; background-color: rgb(245, 245, 245); font-family: &#39;Courier New&#39;; font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; &quot;&gt;&lt;div&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;summary&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; DES3加密解密&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;    &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Des3&lt;br /&gt;  {&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;#region&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; CBC模式**&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;summary&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; DES3 CBC模式加密&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;key&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;密钥&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;iv&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;IV&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;data&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;明文的byte数组&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;密文的byte数组&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;        &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] Des3EncodeCBC( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] iv, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data )&lt;br /&gt;      {&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;复制于MSDN&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;try&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;          {&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create a MemoryStream.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                MemoryStream mStream &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; MemoryStream();&lt;br /&gt;&lt;br /&gt;              TripleDESCryptoServiceProvider tdsp &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; TripleDESCryptoServiceProvider();&lt;br /&gt;              tdsp.Mode &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; CipherMode.CBC;             &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;默认值&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                tdsp.Padding &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; PaddingMode.PKCS7;       &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;默认值&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create a CryptoStream using the MemoryStream&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; and the passed key and initialization vector (IV).&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                CryptoStream cStream &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; CryptoStream( mStream,&lt;br /&gt;                  tdsp.CreateEncryptor( key, iv ),&lt;br /&gt;                  CryptoStreamMode.Write );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Write the byte array to the crypto stream and flush it.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                cStream.Write( data, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;0&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, data.Length );&lt;br /&gt;              cStream.FlushFinalBlock();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Get an array of bytes from the&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; MemoryStream that holds the&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; encrypted data.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] ret &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; mStream.ToArray();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Close the streams.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                cStream.Close();&lt;br /&gt;              mStream.Close();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Return the encrypted buffer.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; ret;&lt;br /&gt;          }&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; ( CryptographicException e )&lt;br /&gt;          {&lt;br /&gt;              Console.WriteLine( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;A Cryptographic error occurred: {0}&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, e.Message );&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;summary&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; DES3 CBC模式解密&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;key&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;密钥&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;iv&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;IV&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;data&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;密文的byte数组&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;明文的byte数组&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;        &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] Des3DecodeCBC( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] iv, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data )&lt;br /&gt;      {&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;try&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;          {&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create a new MemoryStream using the passed&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; array of encrypted data.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                MemoryStream msDecrypt &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; MemoryStream( data );&lt;br /&gt;&lt;br /&gt;              TripleDESCryptoServiceProvider tdsp &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; TripleDESCryptoServiceProvider();&lt;br /&gt;              tdsp.Mode &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; CipherMode.CBC;&lt;br /&gt;              tdsp.Padding &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; PaddingMode.PKCS7;&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create a CryptoStream using the MemoryStream&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; and the passed key and initialization vector (IV).&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                CryptoStream csDecrypt &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; CryptoStream( msDecrypt,&lt;br /&gt;                  tdsp.CreateDecryptor( key, iv ),&lt;br /&gt;                  CryptoStreamMode.Read );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create buffer to hold the decrypted data.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] fromEncrypt &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[data.Length];&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Read the decrypted data out of the crypto stream&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; and place it into the temporary buffer.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                csDecrypt.Read( fromEncrypt, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;0&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, fromEncrypt.Length );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;Convert the buffer into a string and return it.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; fromEncrypt;&lt;br /&gt;          }&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; ( CryptographicException e )&lt;br /&gt;          {&lt;br /&gt;              Console.WriteLine( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;A Cryptographic error occurred: {0}&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, e.Message );&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;#endregion&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;#region&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; ECB模式&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;summary&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; DES3 ECB模式加密&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;key&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;密钥&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;iv&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;IV(当模式为ECB时，IV无用)&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;str&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;明文的byte数组&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;密文的byte数组&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;        &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] Des3EncodeECB( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] iv, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data )&lt;br /&gt;      {&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;try&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;          {&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create a MemoryStream.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                MemoryStream mStream &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; MemoryStream();&lt;br /&gt;&lt;br /&gt;              TripleDESCryptoServiceProvider tdsp &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; TripleDESCryptoServiceProvider();&lt;br /&gt;              tdsp.Mode &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; CipherMode.ECB;&lt;br /&gt;              tdsp.Padding &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; PaddingMode.PKCS7;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create a CryptoStream using the MemoryStream&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; and the passed key and initialization vector (IV).&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                CryptoStream cStream &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; CryptoStream( mStream,&lt;br /&gt;                  tdsp.CreateEncryptor( key, iv ),&lt;br /&gt;                  CryptoStreamMode.Write );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Write the byte array to the crypto stream and flush it.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                cStream.Write( data, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;0&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, data.Length );&lt;br /&gt;              cStream.FlushFinalBlock();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Get an array of bytes from the&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; MemoryStream that holds the&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; encrypted data.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] ret &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; mStream.ToArray();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Close the streams.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                cStream.Close();&lt;br /&gt;              mStream.Close();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Return the encrypted buffer.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; ret;&lt;br /&gt;          }&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; ( CryptographicException e )&lt;br /&gt;          {&lt;br /&gt;              Console.WriteLine( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;A Cryptographic error occurred: {0}&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, e.Message );&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;summary&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; DES3 ECB模式解密&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;key&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;密钥&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;iv&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;IV(当模式为ECB时，IV无用)&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;param name=&quot;str&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;密文的byte数组&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;明文的byte数组&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;        &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] Des3DecodeECB( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] iv, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data )&lt;br /&gt;      {&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;try&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;          {&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create a new MemoryStream using the passed&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; array of encrypted data.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                MemoryStream msDecrypt &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; MemoryStream( data );&lt;br /&gt;&lt;br /&gt;              TripleDESCryptoServiceProvider tdsp &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; TripleDESCryptoServiceProvider();&lt;br /&gt;              tdsp.Mode &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; CipherMode.ECB;&lt;br /&gt;              tdsp.Padding &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; PaddingMode.PKCS7;&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create a CryptoStream using the MemoryStream&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; and the passed key and initialization vector (IV).&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                CryptoStream csDecrypt &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; CryptoStream( msDecrypt,&lt;br /&gt;                  tdsp.CreateDecryptor( key, iv ),&lt;br /&gt;                  CryptoStreamMode.Read );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Create buffer to hold the decrypted data.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] fromEncrypt &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[data.Length];&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Read the decrypted data out of the crypto stream&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; and place it into the temporary buffer.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                csDecrypt.Read( fromEncrypt, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;0&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, fromEncrypt.Length );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;Convert the buffer into a string and return it.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;                &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; fromEncrypt;&lt;br /&gt;          }&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; ( CryptographicException e )&lt;br /&gt;          {&lt;br /&gt;              Console.WriteLine( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;A Cryptographic error occurred: {0}&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, e.Message );&lt;br /&gt;              &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;#endregion&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;summary&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; 类测试&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;///&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;        &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Test()&lt;br /&gt;      {&lt;br /&gt;          System.Text.Encoding utf8 &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; System.Text.Encoding.UTF8;&lt;br /&gt;&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;key为abcdefghijklmnopqrstuvwx的Base64编码&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;            &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Convert.FromBase64String( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; );&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] iv &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] { &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;1&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;3&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;4&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;5&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;6&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;7&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 128); &quot;&gt;8&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; };      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;当模式为ECB时，IV无用&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;            &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; utf8.GetBytes( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;中国ABCabc123&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; );&lt;br /&gt;&lt;br /&gt;          System.Console.WriteLine( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;ECB模式:&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; );&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] str1 &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Des3.Des3EncodeECB( key, iv, data );&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] str2 &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Des3.Des3DecodeECB( key, iv, str1 );&lt;br /&gt;          System.Console.WriteLine( Convert.ToBase64String( str1 ) );&lt;br /&gt;          System.Console.WriteLine( System.Text.Encoding.UTF8.GetString( str2 ) );&lt;br /&gt;&lt;br /&gt;          System.Console.WriteLine();&lt;br /&gt;&lt;br /&gt;          System.Console.WriteLine( &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;CBC模式:&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; );&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] str3 &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Des3.Des3EncodeCBC( key, iv, data );&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] str4 &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Des3.Des3DecodeCBC( key, iv, str3 );&lt;br /&gt;          System.Console.WriteLine( Convert.ToBase64String( str3 ) );&lt;br /&gt;          System.Console.WriteLine( utf8.GetString( str4 ) );&lt;br /&gt;&lt;br /&gt;          System.Console.WriteLine();&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;  }&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt; &lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt; &lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt; &lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;接着是Java代码&lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt; &lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;line-height: 25px; background-color: rgb(245, 245, 245); font-family: &#39;Courier New&#39;; font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; &quot;&gt;&lt;div&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; java.security.Key;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; javax.crypto.Cipher;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; javax.crypto.SecretKeyFactory;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; javax.crypto.spec.DESedeKeySpec;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; javax.crypto.spec.IvParameterSpec;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; sun.misc.BASE64Decoder;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;import&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; sun.misc.BASE64Encoder;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;class&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Des3 {&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;void&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; main(String[] args) &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Exception {&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; BASE64Decoder().decodeBuffer(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] keyiv &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; { &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;1&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;2&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;3&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;4&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;5&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;6&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;7&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;8&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; };&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;中国ABCabc123&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;.getBytes(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;UTF-8&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;   &lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;ECB加密解密&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] str3 &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; des3EncodeECB(key,data );&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] str4 &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; ees3DecodeECB(key, str3);&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; BASE64Encoder().encode(str3));&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; String(str4, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;UTF-8&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;));&lt;br /&gt;&lt;br /&gt;      System.out.println();&lt;br /&gt;&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;CBC加密解密&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] str5 &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; des3EncodeCBC(key, keyiv, data);&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] str6 &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; des3DecodeCBC(key, keyiv, str5);&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; BASE64Encoder().encode(str5));&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; String(str6, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;UTF-8&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;));&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;   * ECB加密,不要IV&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; key 密钥&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; data 明文&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Base64编码的密文&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Exception&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] des3EncodeECB(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data)&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Exception {&lt;br /&gt;&lt;br /&gt;      Key deskey &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;      DESedeKeySpec spec &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; DESedeKeySpec(key);&lt;br /&gt;      SecretKeyFactory keyfactory &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; SecretKeyFactory.getInstance(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;desede&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;      deskey &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; keyfactory.generateSecret(spec);&lt;br /&gt;&lt;br /&gt;      Cipher cipher &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Cipher.getInstance(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;desede&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;/ECB/PKCS5Padding&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;&lt;br /&gt;      cipher.init(Cipher.ENCRYPT_MODE, deskey);&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] bOut &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; cipher.doFinal(data);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; bOut;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;   * ECB解密,不要IV&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; key 密钥&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; data Base64编码的密文&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; 明文&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Exception&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] ees3DecodeECB(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data)&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Exception {&lt;br /&gt;&lt;br /&gt;      Key deskey &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;      DESedeKeySpec spec &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; DESedeKeySpec(key);&lt;br /&gt;      SecretKeyFactory keyfactory &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; SecretKeyFactory.getInstance(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;desede&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;      deskey &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; keyfactory.generateSecret(spec);&lt;br /&gt;&lt;br /&gt;      Cipher cipher &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Cipher.getInstance(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;desede&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;/ECB/PKCS5Padding&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;&lt;br /&gt;      cipher.init(Cipher.DECRYPT_MODE, deskey);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] bOut &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; cipher.doFinal(data);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; bOut;&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;   * CBC加密&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; key 密钥&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; keyiv IV&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; data 明文&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Base64编码的密文&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Exception&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] des3EncodeCBC(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] keyiv, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data)&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Exception {&lt;br /&gt;&lt;br /&gt;      Key deskey &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;      DESedeKeySpec spec &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; DESedeKeySpec(key);&lt;br /&gt;      SecretKeyFactory keyfactory &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; SecretKeyFactory.getInstance(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;desede&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;      deskey &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; keyfactory.generateSecret(spec);&lt;br /&gt;&lt;br /&gt;      Cipher cipher &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Cipher.getInstance(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;desede&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;/CBC/PKCS5Padding&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;      IvParameterSpec ips &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; IvParameterSpec(keyiv);&lt;br /&gt;      cipher.init(Cipher.ENCRYPT_MODE, deskey, ips);&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] bOut &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; cipher.doFinal(data);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; bOut;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;/**&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;   * CBC解密&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; key 密钥&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; keyiv IV&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@param&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; data Base64编码的密文&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; 明文&lt;br /&gt;   * &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(128, 128, 128); &quot;&gt;@throws&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt; Exception&lt;br /&gt;   &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 128, 0); &quot;&gt;*/&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;public&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;static&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] des3DecodeCBC(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] key, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] keyiv, &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] data)&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;throws&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Exception {&lt;br /&gt;&lt;br /&gt;      Key deskey &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;null&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;      DESedeKeySpec spec &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; DESedeKeySpec(key);&lt;br /&gt;      SecretKeyFactory keyfactory &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; SecretKeyFactory.getInstance(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;desede&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;      deskey &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; keyfactory.generateSecret(spec);&lt;br /&gt;&lt;br /&gt;      Cipher cipher &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; Cipher.getInstance(&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;desede&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;/CBC/PKCS5Padding&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;      IvParameterSpec ips &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; IvParameterSpec(keyiv);&lt;br /&gt;&lt;br /&gt;      cipher.init(Cipher.DECRYPT_MODE, deskey, ips);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;byte&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;[] bOut &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; cipher.doFinal(data);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 255); &quot;&gt;return&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Courier New&#39;; color: rgb(0, 0, 0); &quot;&gt; bOut;&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt; &lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt; &lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;下面是运行结果&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ECB模式:&lt;br /&gt;rmWB4+r9Ug93WI0KAEuMig==&lt;br /&gt;中国ABCabc123&lt;br /&gt;&lt;br /&gt;CBC模式:&lt;br /&gt;4aabWF8UFour/vNfnzJrjw==&lt;br /&gt;中国ABCabc123&lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;source: &lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;a href=&quot;http://www.cnblogs.com/neil-zhao/archive/2011/06/01/2066058.html&quot;&gt;http://www.cnblogs.com/neil-zhao/archive/2011/06/01/2066058.html&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; &quot;&gt;&lt;a href=&quot;http://gaoge2000.blog.hexun.com/18731819_d.html&quot;&gt;http://gaoge2000.blog.hexun.com/18731819_d.html&lt;/a&gt;&lt;/p&gt;&lt;p style=&quot;font-family: Arial; font-size: 14px; line-height: 25px; &quot;&gt;&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/5830703976652903774/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/5830703976652903774' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5830703976652903774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5830703976652903774'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/06/javac3des.html' title='JAVA和C＃3DES加密解密'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-4725811511699602609</id><published>2011-06-14T19:35:00.000-07:00</published><updated>2011-07-08T01:00:00.824-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><title type='text'>Certificate Encryption/Decryption Example on C#</title><content type='html'>The following are example functions using a PKCS12 cert. (It has both public and private keys) and the result is encoded/decoded by base64.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;font-family:&#39;Times New Roman&#39;;font-size:medium;&quot;&gt;static string&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;b style=&quot;color: black; background-color: rgb(255, 153, 153);&quot;&gt;Decrypt&lt;/b&gt;(string data)&lt;br /&gt;      {&lt;br /&gt;         &lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;b style=&quot;color: black; background-color: rgb(255, 255, 102);&quot;&gt;X509Certificate2&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;myCertificate = new&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;b style=&quot;color: black; background-color: rgb(255, 255, 102);&quot;&gt;X509Certificate2&lt;/b&gt;(&quot;c:\\temp&lt;wbr&gt;\\mycerts.&lt;wbr&gt;p12&quot;,&quot;1234&lt;wbr&gt;56&quot;);&lt;br /&gt;         &lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;&lt;b style=&quot;color: black; background-color: rgb(153, 255, 153);&quot;&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt; &lt;/span&gt;provider1 = (&lt;b style=&quot;color: black; background-color: rgb(153, 255, 153);&quot;&gt;RSACryptoServiceProvider&lt;/b&gt;)&lt;wbr&gt;myCertific&lt;wbr&gt;ate.Privat&lt;wbr&gt;eKey;&lt;br /&gt;          byte[] buffer1 = Convert.FromBase64String(d&lt;wbr&gt;ata);&lt;br /&gt;          byte[] result = provider1.&lt;b style=&quot;color: black; background-color: rgb(255, 153, 153);&quot;&gt;Decrypt&lt;/b&gt;(buffer1,&lt;wbr&gt;false);&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;orphans: 2; text-indent: 0px; widows: 2; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;return Encoding.UTF8.GetString(result);&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;//return (new UnicodeEncoding()).GetStri&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;ng(result)&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;       }&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;       static string Encrypt(string data)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;       {&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); &quot;&gt;X509Certificate2&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;myCertificate = new&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); &quot;&gt;X509Certificate2&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;(&quot;c:\\temp&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;\\mycerts.&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;p12&quot;, &quot;123456&quot;);&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); &quot;&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;provider1 = (&lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); &quot;&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;)&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;myCertific&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;ate.Public&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;Key.Key;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;//byte[] buffer1 = (new UnicodeEncoding()).GetByte&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;s(data);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;orphans: 2; text-indent: 0px; widows: 2; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;byte[] buffer1 = Encoding.UTF8.GetBytes(data);&lt;br /&gt;          byte[] result = provider1.Encrypt(buffer1,&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;false);&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;           string b64s = Convert.ToBase64String(res&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;ult);&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;           return b64s;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;       static bool VerifyData(string data, string signature)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;       {&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); &quot;&gt;X509Certificate2&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;myCertificate = new&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); &quot;&gt;X509Certificate2&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;(&quot;c:\\temp&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;\\mycerts.&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;p12&quot;, &quot;123456&quot;);&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); &quot;&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;provider1 = (&lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); &quot;&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;)&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;myCertific&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;ate.Public&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;Key.Key;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;           byte[] sb = Convert.FromBase64String(s&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;ignature);&lt;/span&gt;&lt;wbr&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;&lt;div&gt;//byte[] db = (new ASCIIEncoding()).GetBytes(data);&lt;/div&gt;&lt;div&gt;  byte[] db = Encoding.UTF8.GetBytes(data);&lt;/div&gt;          return provider1.VerifyData(db, new SHA1CryptoServiceProvider(&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;), sb);&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;       static string SignData(string data)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;       {&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); &quot;&gt;X509Certificate2&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;myCertificate = new&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); &quot;&gt;X509Certificate2&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;(&quot;c:\\temp&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;\\mycerts.&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;p12&quot;, &quot;123456&quot;);&lt;/span&gt;&lt;br /&gt;         &lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); &quot;&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;provider1 = (&lt;/span&gt;&lt;b style=&quot;border-collapse: separate; font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); &quot;&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;)&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;myCertific&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;ate.Privat&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;eKey;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;; font-size: medium; &quot;&gt;//byte[] db = (new ASCIIEncoding()).GetBytes(data);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;orphans: 2; text-indent: 0px; widows: 2; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;&lt;div&gt;byte[] db = Encoding.UTF8.GetBytes(data);&lt;/div&gt;            byte[] sb = provider1.SignData(db, new SHA1CryptoServiceProvider(&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;));&lt;/span&gt;&lt;span class=&quot;Apple-converted-space&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; &quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;            return Convert.ToBase64String(sb)&lt;/span&gt;&lt;wbr&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  &gt;       }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/4725811511699602609/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/4725811511699602609' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/4725811511699602609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/4725811511699602609'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/06/x509certificate2-encrypt-decrypt-using.html' title='Certificate Encryption/Decryption Example on C#'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-325106467345406500</id><published>2011-05-25T21:21:00.001-07:00</published><updated>2011-05-25T21:22:23.173-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java的編碼問題匯總</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif; &quot; &gt;&lt;span title=&quot;&quot;&gt;&lt;br /&gt;   &lt;/span&gt;&lt;span title=&quot;&quot;&gt;問題一：在JAVA中讀取文件時應該採用什麼編碼？&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;Java的讀取文件的方式總體可以分為兩類：按字節讀取和按字符讀取。按字節讀取就是採用 InputStream.read（）執行方法來讀取字節，然後保存到一個字節 []&lt;/span&gt;&lt;span title=&quot;&quot;&gt;數組中，最後經常用新的字符串（字節 []）;把字節數組轉換成字符串。在最後一步隱藏了一個編碼的細節，新的字符串（字節 []）;會使用操作系統默認的字符集來解碼&lt;/span&gt;&lt;span title=&quot;&quot;&gt;字節數組，中文操作系統就是GBK的。而我們從輸入流裡讀取的字節很可能就不是GBK的編碼的，因為從輸入流裡讀取的字節編碼取決於被讀取的文件自身的編碼&lt;/span&gt;&lt;span title=&quot;&quot;&gt;。舉個例子：我們在ð：盤新建一個名為 demo.txt的文件，寫入“我們。”並保存。此時 demo.txt編碼是ANSI和中文操作系統下就是GBK的。此時我們用&lt;/span&gt;&lt;span title=&quot;&quot;&gt;輸入字節流讀取該文件所得到的字節就是使用GBK的方式編碼的字節。那麼我們最終新的字符串（字節 []）;時採用平台默認的GBK的來編碼成字符串也是沒有問題的（字節&lt;/span&gt;&lt;span title=&quot;&quot;&gt;編碼和默認解碼一致）。試想一下，如果在保存demo.txt文件時，我們選擇的UTF - 8編碼，那麼該文件的編碼就不在是的ANSI了，而變成了UTF - 8的。仍然採用輸入字節&lt;/span&gt;&lt;span title=&quot;&quot;&gt;流來讀取，那麼此時讀取的字節和上一次就不一樣了，這次的字節是使用UTF - 8編碼的字節。兩次的字節顯然不一樣，一個很明顯的區別就是&lt;/span&gt;&lt;span title=&quot;&quot;&gt;：GBK的每個漢字兩個字節，而UTF - 8的每個漢字三個字節。如何我們最後還使用新字符串（字節 []）;來構造字符串對象，則會出現亂碼，原因很簡單，因為&lt;/span&gt;&lt;span title=&quot;&quot;&gt;構造時採用的默認解碼 GBK的，而我們的字節是使用UTF - 8字節。正確的辦法就是使用新的字符串（字節 []“的UTF - 8”）;來構造的String對象。此時我們的字節&lt;/span&gt;&lt;span title=&quot;&quot;&gt;編碼和構造使用的解碼是一致的，不會出現亂碼問題了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;說完字節輸入流，再來說說字節輸出流。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;我們知道如果採用字節輸出流把字節輸出到某個文件，我們是無法指定生成文件的編碼的（假設文件以前不存在），那麼生成的文件是什麼編碼的呢？經過測試發現，其實這&lt;/span&gt;&lt;span title=&quot;&quot;&gt;取決於寫入的字節編碼格式。比如以下代碼：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;OutputStream的輸出 =新FileOutputStream（為“D：\ \ demo.txt”）;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;out.write（“我們”。getBytes（）構造）;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;getBytes（）構造會採用操作系統默認的字符集來編碼字節，這裡就是GBK的，所以我們寫入文件的是GBK的demo.txt編碼的字節。那麼這個文件的編碼就是GBK的。如果稍微修改一下程序： &lt;/span&gt;&lt;span title=&quot;&quot;&gt;out.write（“我們”。的GetBytes（“使用UTF - 8”））;此時我們寫入的字節就是使用UTF - 8的，那麼 demo.txt文件編碼就是使用UTF - 8。這裡還有一點，如果把&lt;/span&gt;&lt;span title=&quot;&quot;&gt;“我們”換成 123或農業銀行之類的的ASCII碼字符，那麼無論是採用的GetBytes（）或者的GetBytes（“使用UTF - 8”），那麼生成的文件都將是GBK的編碼的。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;這裡可以總結一下，輸入流中的字節編碼取決文件本身的編碼，而OutputStream的生成文件的編碼取決於字節的編碼。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;下面說說採用字符輸入流來讀取文件。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;首先，我們需要理解一下字符流。其實字符流可以看做是一種包裝流，它的底層還是採用字節流來讀取字節，然後它使用指定的編碼方式將讀取字節解碼為字符&lt;/span&gt;&lt;span title=&quot;&quot;&gt;。說起字符流，不得不提的就是的InputStreamReader。以下是Java API的對它的說明：的InputStreamReader是字節流通向字符流的橋樑：它使用指定的字符集讀取字節並將其解碼為字符。它&lt;/span&gt;&lt;span title=&quot;&quot;&gt;使用的字符集可以由名稱指定或顯式給定，否則可能接受平台默認的字符集。說到這裡其實很明白了，的InputStreamReader在底層還是採用字節流來讀取字節，讀取字節後&lt;/span&gt;&lt;span title=&quot;&quot;&gt;它需要一個編碼格式來解碼讀取的字節，如果我們在構造的InputStreamReader沒有傳入編碼方式，那麼會採用操作系統默認的GBK的來解碼讀取的字節。demo.txt還用上面的例子，假設&lt;/span&gt;&lt;span title=&quot;&quot;&gt;編碼方式為 GBK的demo.txt，我們使用如下代碼來讀取文件：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;在新的InputStreamReader的InputStreamReader =（新FileInputStream的（“demo.txt”））;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;那麼我們讀取不會產生亂碼，因為文件採用 GBK的編碼，所以讀出的字節也是GBK的編碼的，而的InputStreamReader默認採用解碼也是GBK的。如果把demo.txt編碼方式換成 UTF - 8的，那麼我們採用&lt;/span&gt;&lt;span title=&quot;&quot;&gt;這種方式讀取就會產生亂碼。這是因為字節編碼（使用UTF - 8）和我們的解碼編碼（GBK的）造成的。解決辦法如下：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;在新的InputStreamReader的InputStreamReader =（新FileInputStream的（“demo.txt”），“使用UTF - 8”）;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;給的InputStreamReader指定解碼編碼，這樣二者統一就不會出現亂碼了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;下面說說字符輸出流。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;字符輸出流的原理和字符輸入流的原理一樣，也可以看做是包裝流，其底層還是採用字節輸出流來寫文件。只是字符輸出流根據指定的編碼將字符轉換為字節的。字符&lt;/span&gt;&lt;span title=&quot;&quot;&gt;輸出流的主要類是：OutputStreamWriter。Java API的解釋如下：OutputStreamWriter是字符流通向字節流的橋樑：使用指定的字符集將要向其寫入的字符編碼為字節。它使用的字符集可以由名稱指定&lt;/span&gt;&lt;span title=&quot;&quot;&gt;或顯式給定，否則可能接受平台默認的字符集。說的很明白了，它需要一個編碼將寫入的字符轉換為字節，如果沒有指定則採用 GBK的編碼，那麼輸出的字節都將&lt;/span&gt;&lt;span title=&quot;&quot;&gt;是GBK的編碼，生成的文件也是GBK的編碼的。如果採用以下方式構造 OutputStreamWriter：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;OutputStreamWriter輸出 =新OutputStreamWriter（新FileOutputStream（“dd.txt”），“使用UTF - 8”）;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;那麼寫入的字符將被編碼為 UTF - 8編碼的字節，生成的文件也將是使用UTF - 8格式的。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;問題二：既然讀文件要使用和文件編碼一致的編碼，那麼 javac的編譯文件也需要讀取文件，它使用什麼編碼呢？&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;這個問題從來就沒想過，也從沒當做是什麼問題。正是因為問題一而引發的思考，其實這裡還是有東西可以挖掘的。下面分三種情況來探討，這三種情況也是我們常用&lt;/span&gt;&lt;span title=&quot;&quot;&gt;的編譯的Java源文件的方法。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;1.javac在控制台編譯的Java類文件。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;通常我們手動建立一個 java的文件Demo.java，並保存。此時 Demo.java文件的編碼為 ANSI和中文操作系統下就是GBK的。然後使用javac的命令來編譯該源文件。“javac的Demo.java”。javac的&lt;/span&gt;&lt;span title=&quot;&quot;&gt;也需要讀取的Java文件，那麼 javac的是使用什麼編碼來解碼我們讀取的字節呢？其實 javac的採用了操作系統默認的GBK的編碼解碼我們讀取的字節，這個編碼正好也是Demo.java文件的&lt;/span&gt;&lt;span title=&quot;&quot;&gt;編碼，二者一致，所以不會出現亂碼情況。讓我們來做點手腳，在保存Demo.java文件時，我們選擇的UTF - 8保存。此時 Demo.java文件編碼就是UTF - 8的了。我們再&lt;/span&gt;&lt;span title=&quot;&quot;&gt;使用“javac的Demo.java”來編譯，如果Demo.java裡含有中文字符，此時控制台會出現警告信息，也出現了亂碼。究其原因，就是因為採用了GBK的javac的編碼解碼我們讀取的字&lt;/span&gt;&lt;span title=&quot;&quot;&gt;節。因為我們的字節是使用UTF - 8編碼的，所以會出現亂碼。如果不信的話你可以自己試試。那麼解決辦法呢？解決辦法就是使用的javac的編碼參數來制定我們的解碼編碼。如下： &lt;/span&gt;&lt;span title=&quot;&quot;&gt;javac的編碼的UTF - 8 Demo.java。這裡我們指定了使用的UTF - 8來解碼讀取的字節，由於這個編碼和Demo.java文件編碼一致，所以不會出現亂碼情況了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;2.Eclipse中編譯的Java文件。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;我習慣把Eclipse中的編碼設置成UTF - 8的。那麼每個項目中的Java的源文件的編碼就是使用UTF - 8。這樣編譯也從沒有問題，也沒有出現過亂碼。正是因為這樣才掩蓋了使用javac的&lt;/span&gt;&lt;span title=&quot;&quot;&gt;可能出現的亂碼。那麼 Eclipse的是如何正確編譯文件編碼為 UTF - 8編碼的Java的源文件的呢？唯一的解釋就是Eclipse的自動識別了我們的Java源文件的文件編碼，然後採取了正確的編碼參數來編譯&lt;/span&gt;&lt;span title=&quot;&quot;&gt;我們的Java的源文件。功勞都歸功於 IDE中的強大了。&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;3。使用的Ant來編譯的Java文件。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;螞蟻也是我常用的編譯的Java文件的工具。首先，必須知道螞蟻在後台其實也是採用的javac來編譯的Java源文件的，那麼可想而知，一會出現的問題在螞蟻中也會存在。如果我們使用&lt;/span&gt;&lt;span title=&quot;&quot;&gt;螞蟻來編譯的UTF - 8編碼的Java的源文件，並且不指定如何編碼，那麼也會出現亂碼的情況。所以螞蟻的編譯命令&lt;javac&gt;有一個屬性“編碼”允許我們指定編碼，如果我們要編譯源&lt;/javac&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;文件編碼為 UTF - 8編碼的java的文件，那麼我們的命令應該如下：&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;&lt;javac的了destdir utf=&quot;&quot; span=&quot;&quot;&gt;&lt;span title=&quot;&quot;&gt;“&amp;gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;指定了編碼也就相當於“javac的編碼”了，所以不會出現亂碼了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;問題三：tomcat的中編譯的JSP的情況。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;這個話題也是由問題二引出的。既然javac的編譯的Java源文件需要採用正確的編碼，那麼 Tomcat的編譯的JSP時也要讀取文件，此時的Tomcat採用什麼編碼來讀取文件？會出現亂碼情況嗎？下面&lt;/span&gt;&lt;span title=&quot;&quot;&gt;我們來分析。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=&quot;&quot;&gt;我們通常會在jsp的開頭寫上如下代碼：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;&amp;lt;％@網頁的語言 =“爪哇”的contentType =“text / html的，字符集= UTF - 8”pageEncoding =“的UTF - 8”％&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;我常常不寫 pageEncoding這個屬於，也不明白它的作用，但是不寫也沒出現過亂碼情況。其實這個屬性就是告訴 tomcat的採用什麼編碼來讀取 JSP的文件的。它應該和jsp的文件本身的編碼一致&lt;/span&gt;&lt;span title=&quot;&quot;&gt;。比如我們新建個 jsp的文件，設置文件編碼為 GBK的，那麼此時我們的pageEncoding應該設置為 GBK的，這樣我們寫入文件的字符就是GBK的編碼的，Tomcat的讀取文件時採用也是GBK的編碼，所以能保證&lt;/span&gt;&lt;span title=&quot;&quot;&gt;正確的解碼讀取的字節。不會出現亂碼。如果把pageEncoding設置為 UTF - 8的，那麼讀取的jsp文件過程中轉碼就出現了亂碼。上面說我常常不寫 pageEncoding這個屬性，但是也沒出現&lt;/span&gt;&lt;span title=&quot;&quot;&gt;過亂碼，這是怎麼回事呢？那是因為如果沒有 pageEncoding屬性中，Tomcat會採用的contentType中字符集編碼來讀取 jsp的文件，我的jsp的文件編碼通常設置為 UTF - 8編碼，字符集的contentType的也設置為使用UTF &lt;/span&gt;&lt;span title=&quot;&quot;&gt;-8，這樣的Tomcat使用的UTF - 8編碼來解碼讀取的jsp的文件，二者編碼一致也不會出現亂碼。這只是中的contentType字符集的一個作用，它還有兩個作用，後面再說。可能有人會&lt;/span&gt;&lt;span title=&quot;&quot;&gt;問：如果我既不設置 pageEncoding屬性，也不設置的contentType的字符集屬性，那麼 Tomcat的會採取什麼編碼來解碼讀取的jsp的文件呢？答案是異 - 8859 - 1，這是Tomcat的讀取文件採用的默認&lt;/span&gt;&lt;span title=&quot;&quot;&gt;編碼，如果用這種編碼來讀取文件顯然會出現亂碼。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;/span&gt;&lt;span title=&quot;&quot;&gt;問題四：輸出。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;問題二和問題三分析的過程其實就是從源文件àclass文件過程中的轉碼情況。最終的類文件都是以Unicode的編碼的，我們前面所做的工作就是把各種不同的編碼轉換為 Unicode的編碼&lt;/span&gt;&lt;span title=&quot;&quot;&gt;，比如從 GBK的轉換為 Unicode編碼，從使用UTF - 8轉換為 Unicode的。因為只有採用正確的編碼來轉碼才能保證不出現亂碼。在jvm在運行時其內部都是採用的Unicode編碼的，其實在輸出時，又&lt;/span&gt;&lt;span title=&quot;&quot;&gt;會做一次編碼的轉換。讓我們分兩種情況來討論。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;1.java中採用 Sysout.out.println輸出。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;比如：Sysout.out.println（“我們”）。經過正確的解碼後“我們”是unicode的保存在內存中的，但是在向標準輸出（控制台）輸出時，jvm的又做了一次轉碼，它&lt;/span&gt;&lt;span title=&quot;&quot;&gt;會採用操作系統默認編碼（中文操​​作系統是GBK的），將內存中的Unicode的編碼轉換為 GBK的編碼，然後輸出到控制台。因為我們操作系統是中文系統，所以往終端顯示設備上打印字符時使用的&lt;/span&gt;&lt;span title=&quot;&quot;&gt;也是GBK的編碼。因為終端的編碼無法手動改變，所以這個過程對我們來說是透明的，只要編譯時能正確轉碼，最終的輸出都將是正確的，不會出現亂碼。在Eclipse中中可以設置&lt;/span&gt;&lt;span title=&quot;&quot;&gt;控制台的字符編碼，具體位置在運行配置對話框的通用標籤裡，我們可以試著設置為 UTF - 8的，此時的輸出就是亂碼了。因為輸出時是採用 GBK的編碼的，而顯示卻是使用&lt;/span&gt;&lt;span title=&quot;&quot;&gt;使用UTF - 8，編碼不同，所以出現亂碼。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;2.jsp中使用out.println（）輸出到客戶端瀏覽器。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;JSP的編譯成類後，如果輸出到客戶端，也有個轉碼的過程。爪哇會採用操作系統默認的編碼來轉碼，那麼 Tomcat的採用什麼編碼來轉碼呢？其實 tomcat的是根據 &amp;lt;％@網頁的語言&lt;/span&gt;&lt;span title=&quot;&quot;&gt;=“爪哇”的contentType =“text / html的，字符集= UTF - 8”pageEncoding =“的UTF - 8”％&amp;gt;中的contentType的字符集參數來轉碼的，用來設置的contentType Tomcat的往瀏覽器發送的HTML內容所使用的&lt;/span&gt;&lt;span title=&quot;&quot;&gt;編碼。Tomcat的根據這個編碼來轉碼內存中的Unicode的。經過轉碼後的Tomcat輸出到客戶端的字符編碼就是utf - 8的了。那麼瀏覽器怎麼知道採取什麼編碼格式來顯示接收到的內容呢？這就是&lt;/span&gt;&lt;span title=&quot;&quot;&gt;contentType中的字符集屬性的第三個作用了：這個編碼會在HTTP的響應頭中指定以通知瀏覽器。瀏覽器使用的HTTP響應頭的contentType中的字符集屬性來顯示接收到的內容。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;總結一下的contentType字符集的三個作用：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;1）。在沒有 pageEncoding屬性時，Tomcat的使用它來解碼讀取的jsp的文件。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;2）。Tomcat的向客戶端輸出時，使用它來編碼發送的內容。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;3）。通知瀏覽器，應該以什麼編碼來顯示接收到的內容。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;為了能更好的理解上面所說的解碼和轉碼過程，我們舉一個例子。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;新建一個 index.jsp的文件，該文件編碼為 GBK的，在jsp的開頭我們寫上如下代碼：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;&amp;lt;％@網頁的語言 =“爪哇”的contentType =“text / html的，字符集= UTF - 8”pageEncoding =“GBK的”％&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=&quot;&quot;&gt;這裡的字符集和pageEncoding不同，但是也不會出現亂碼，我來解釋一下。首先Tomcat的讀取 jsp的內容，並根據 pageEncoding指定的GBK的編碼將讀取的GBK的字節解碼並轉換為 Unicode的字節碼保存在&lt;/span&gt;&lt;span title=&quot;&quot;&gt;類文件中。然後 tomcat的在輸出時（out.println（））使用字符集屬性將內存中的Unicode的轉換為 UTF - 8的編碼，並在響應頭中通知瀏覽器，瀏覽器以UTF - 8的顯示接收到的&lt;/span&gt;&lt;span title=&quot;&quot;&gt;內容。整個過程沒有一次轉碼錯誤，所以就不會出現亂碼情況。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;/span&gt;&lt;span title=&quot;&quot;&gt;問題五：屬性和ResourceBundle的使用的解碼編碼。&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span title=&quot;&quot;&gt;以上兩個是我們常用的類，他們在讀取文件過程中並不允許我們指定解碼編碼，那麼它們採取什麼解碼方式呢？查看源碼後發現都是採用異 - 8859 - 1編碼來解碼&lt;br /&gt;          &lt;/span&gt;&lt;span title=&quot;&quot;&gt;的。這樣的話我們也不難理解我們寫的屬性文件為什麼都是異 - 8859 - 1的了。因為採取任何一個別的編碼都將產生亂碼。因為異 - 8859 - 1編碼是沒&lt;br /&gt;          &lt;/span&gt;&lt;span title=&quot;&quot; style=&quot;background-color: rgb(235, 239, 249); &quot;&gt;有中文的，所以我們輸入的中文要轉換為 unicode的，通常我們使用插件來完成，也可以使用的JDK自帶的native2ascii的工具。&lt;/span&gt;&lt;/javac的了destdir&gt;&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif; &quot;&gt;&lt;span title=&quot;&quot; style=&quot;background-color: rgb(235, 239, 249); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, sans-serif; &quot;&gt;&lt;span title=&quot;&quot; style=&quot;background-color: rgb(235, 239, 249); &quot;&gt;source : &lt;/span&gt;&lt;/span&gt;&lt;a href=&quot;http://www.blogjava.net/zhangchao/archive/2011/05/26/351051.html&quot;&gt;http://www.blogjava.net/zhangchao/archive/2011/05/26/351051.html&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/325106467345406500/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/325106467345406500' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/325106467345406500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/325106467345406500'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/05/java.html' title='Java的編碼問題匯總'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-785219563319921458</id><published>2011-04-25T03:57:00.000-07:00</published><updated>2011-04-25T03:58:11.905-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="IOS"/><title type='text'>iOS開發中常用代碼解釋</title><content type='html'>&lt;div&gt;#include  /* 说明 malloc, NULL, size_t */&lt;/div&gt;&lt;div&gt;#include  /* 说明 va_ 相关类型和函数 */&lt;/div&gt;&lt;div&gt;#include  /* 说明 strcat 等 */&lt;/div&gt;&lt;div&gt;char *vstrcat(const char *first, ...)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;size_t len;&lt;/div&gt;&lt;div&gt;char *retbuf;&lt;/div&gt;&lt;div&gt;va_list argp;&lt;/div&gt;&lt;div&gt;char *p;&lt;/div&gt;&lt;div&gt;if(first == NULL)&lt;/div&gt;&lt;div&gt;return NULL;&lt;/div&gt;&lt;div&gt;len = strlen(first);&lt;/div&gt;&lt;div&gt;va_start(argp, first);&lt;/div&gt;&lt;div&gt;while((p = va_arg(argp, char *)) != NULL)&lt;/div&gt;&lt;div&gt;len += strlen(p);&lt;/div&gt;&lt;div&gt;va_end(argp);&lt;/div&gt;&lt;div&gt;retbuf = malloc(len + 1); /* +1 包含终止符 \0 */&lt;/div&gt;&lt;div&gt;if(retbuf == NULL)&lt;/div&gt;&lt;div&gt;return NULL; /* 出错 */&lt;/div&gt;&lt;div&gt;(void)strcpy(retbuf, first);&lt;/div&gt;&lt;div&gt;va_start(argp, first); /* 重新开始扫描 */&lt;/div&gt;&lt;div&gt;while((p = va_arg(argp, char *)) != NULL)&lt;/div&gt;&lt;div&gt;(void)strcat(retbuf, p);&lt;/div&gt;&lt;div&gt;va_end(argp);&lt;/div&gt;&lt;div&gt;retbuf = malloc(len + 1); /* +1 包含终止符 \0 */&lt;/div&gt;&lt;div&gt;if(retbuf == NULL)&lt;/div&gt;&lt;div&gt;return NULL; /* 出错 */&lt;/div&gt;&lt;div&gt;(void)strcpy(retbuf, first);&lt;/div&gt;&lt;div&gt;va_start(argp, first); /* 重新开始扫描 */&lt;/div&gt;&lt;div&gt;while((p = va_arg(argp, char *)) != NULL)&lt;/div&gt;&lt;div&gt;(void)strcat(retbuf, p);&lt;/div&gt;&lt;div&gt;va_end(argp);&lt;/div&gt;&lt;div&gt;return retbuf;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;%c 一个单一的字符&lt;/div&gt;&lt;div&gt;%d 一个十进制整数&lt;/div&gt;&lt;div&gt;%i 一个整数&lt;/div&gt;&lt;div&gt;%e, %f, %g 一个浮点数&lt;/div&gt;&lt;div&gt;%o 一个八进制数&lt;/div&gt;&lt;div&gt;%s 一个字符串&lt;/div&gt;&lt;div&gt;%x 一个十六进制数&lt;/div&gt;&lt;div&gt;%p 一个指针&lt;/div&gt;&lt;div&gt;%n 一个等于读取字符数量的整数&lt;/div&gt;&lt;div&gt;%u 一个无符号整数&lt;/div&gt;&lt;div&gt;%[] 一个字符集&lt;/div&gt;&lt;div&gt;%% 一个精度符号 &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//一、NSString&lt;/div&gt;&lt;div&gt;    /*----------------创建字符串的方法----------------*/&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    1、创建常量字符串。&lt;/div&gt;&lt;div&gt;    NSString *astring = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    2、创建空字符串，给予赋值。&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] init];&lt;/div&gt;&lt;div&gt;    astring = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;astring:%@&quot;,astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    3、在以上方法中，提升速度:initWithString方法&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] initWithString:@&quot;This is a String!&quot;];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;astring:%@&quot;,astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    4、用标准c创建字符串:initWithCString方法&lt;/div&gt;&lt;div&gt;    char *Cstring = &quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] initWithCString:Cstring];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;astring:%@&quot;,astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    5、创建格式化字符串:占位符（由一个%加一个字符组成）&lt;/div&gt;&lt;div&gt;    int i = 1;&lt;/div&gt;&lt;div&gt;    int j = 2;&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc]&lt;/div&gt;&lt;div&gt;                        initWithString:[NSString stringWithFormat:@&quot;%d.This is %i string!&quot;,i,j]];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;astring:%@&quot;,astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    6、创建临时字符串&lt;/div&gt;&lt;div&gt;    NSString *astring;&lt;/div&gt;&lt;div&gt;    astring = [NSString stringWithCString:&quot;This is a temporary string&quot;];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;astring:%@&quot;,astring);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------从文件读取字符串:initWithContentsOfFile方法 ----------------*/&lt;/div&gt;&lt;div&gt;    NSString *path = @&quot;astring.text&quot;;&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] initWithContentsOfFile:path];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;astring:%@&quot;,astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------写字符串到文件:writeToFile方法 ----------------*/&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] initWithString:@&quot;This is a String!&quot;];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;astring:%@&quot;,astring);&lt;/div&gt;&lt;div&gt;    NSString *path = @&quot;astring.text&quot;;&lt;/div&gt;&lt;div&gt;    [astring writeToFile: path atomically: YES];&lt;/div&gt;&lt;div&gt;    [astring release];    &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*---------------- 比较两个字符串----------------*/&lt;/div&gt;&lt;div&gt;    用C比较:strcmp函数&lt;/div&gt;&lt;div&gt;    char string1[] = &quot;string!&quot;;&lt;/div&gt;&lt;div&gt;    char string2[] = &quot;string!&quot;;&lt;/div&gt;&lt;div&gt;    if(strcmp(string1, string2) = = 0)&lt;/div&gt;&lt;div&gt;    {&lt;/div&gt;&lt;div&gt;        NSLog(@&quot;1&quot;);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    isEqualToString方法&lt;/div&gt;&lt;div&gt;    NSString *astring01 = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 isEqualToString:astring02];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;result:%d&quot;,result);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    compare方法(comparer返回的三种值)&lt;/div&gt;&lt;div&gt;    NSString *astring01 = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 compare:astring02] = = NSOrderedSame;&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;result:%d&quot;,result);&lt;/div&gt;&lt;div&gt;    NSOrderedSame 判断两者内容是否相同&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSString *astring01 = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @&quot;this is a String!&quot;;&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 compare:astring02] = = NSOrderedAscending;&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;result:%d&quot;,result);&lt;/div&gt;&lt;div&gt;    //NSOrderedAscending 判断两对象值的大小(按字母顺序进行比较，astring02大于astring01为真)&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSString *astring01 = @&quot;this is a String!&quot;;&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 compare:astring02] = = NSOrderedDescending;&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;result:%d&quot;,result);&lt;/div&gt;&lt;div&gt;    //NSOrderedDescending 判断两对象值的大小(按字母顺序进行比较，astring02小于astring01为真)&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    不考虑大 小写比较字符串1&lt;/div&gt;&lt;div&gt;    NSString *astring01 = @&quot;this is a String!&quot;;&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 caseInsensitiveCompare:astring02] = = NSOrderedSame;&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;result:%d&quot;,result);&lt;/div&gt;&lt;div&gt;    //NSOrderedDescending判断两对象值的大小(按字母顺序进行比较，astring02小于astring01为 真)&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    不考虑大小写比较字符串2&lt;/div&gt;&lt;div&gt;    NSString *astring01 = @&quot;this is a String!&quot;;&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @&quot;This is a String!&quot;;&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 compare:astring02&lt;/div&gt;&lt;div&gt;                            options:NSCaseInsensitiveSearch | NSNumericSearch] = = NSOrderedSame;&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;result:%d&quot;,result);     &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //NSCaseInsensitiveSearch:不区分大小写比较 NSLiteralSearch:进行完全比较，区分大小写 NSNumericSearch:比较字符串的字符个数，而不是字符值。&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------改变字符串的大小写----------------*/&lt;/div&gt;&lt;div&gt;    NSString *string1 = @&quot;A String&quot;;&lt;/div&gt;&lt;div&gt;    NSString *string2 = @&quot;String&quot;;&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;string1:%@&quot;,[string1 uppercaseString]);//大写&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;string2:%@&quot;,[string2 lowercaseString]);//小写&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;string2:%@&quot;,[string2 capitalizedString]);//首字母大小&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------在串中搜索子串 ----------------*/&lt;/div&gt;&lt;div&gt;    NSString *string1 = @&quot;This is a string&quot;;&lt;/div&gt;&lt;div&gt;    NSString *string2 = @&quot;string&quot;;&lt;/div&gt;&lt;div&gt;    NSRange range = [string1 rangeOfString:string2];&lt;/div&gt;&lt;div&gt;    int location = range.location;&lt;/div&gt;&lt;div&gt;    int leight = range.length;&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc]&lt;/div&gt;&lt;div&gt;                        initWithString:[NSString stringWithFormat:@&quot;Location:%i,Leight:%i&quot;&lt;/div&gt;&lt;div&gt;                        ,location,leight]];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;astring:%@&quot;,astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------抽取子串 ----------------*/&lt;/div&gt;&lt;div&gt;    -substringToIndex: 从字符串的开头一直截取到指定的位置，但不包括该位置的字符&lt;/div&gt;&lt;div&gt;    NSString *string1 = @&quot;This is a string&quot;;&lt;/div&gt;&lt;div&gt;    NSString *string2 = [string1 substringToIndex:3];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;string2:%@&quot;,string2);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    -substringFromIndex: 以指定位置开始（包括指定位置的字符），并包括之后的全部字符&lt;/div&gt;&lt;div&gt;    NSString *string1 = @&quot;This is a string&quot;;&lt;/div&gt;&lt;div&gt;    NSString *string2 = [string1 substringFromIndex:3];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;string2:%@&quot;,string2);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    -substringWithRange: //按照所给出的位置，长度，任意地从字符串中截取子串&lt;/div&gt;&lt;div&gt;    NSString *string1 = @&quot;This is a string&quot;;&lt;/div&gt;&lt;div&gt;    NSString *string2 = [string1 substringWithRange:NSMakeRange(0, 4)];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;string2:%@&quot;,string2); &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;const char *fieldValue = [value  cStringUsingEncoding:NSUTF8StringEncoding];&lt;/div&gt;&lt;div&gt;const char *fieldValue = [value UTF8String];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;NSString 转 NSData&lt;/div&gt;&lt;div&gt;NSString* str= @&quot;kilonet&quot;;&lt;/div&gt;&lt;div&gt;NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;   Date format用法：&lt;/div&gt;&lt;div&gt;  -(NSString *) getDay:(NSDate *) d&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;    NSString *s ;&lt;/div&gt;&lt;div&gt;    NSDateFormatter *format = [[NSDateFormatter alloc] init];&lt;/div&gt;&lt;div&gt;    [format setDateFormat:@&quot;YYYY/MM/dd hh:mm:ss&quot;];&lt;/div&gt;&lt;div&gt;    s = [format stringFromDate:d];&lt;/div&gt;&lt;div&gt;    [format release];&lt;/div&gt;&lt;div&gt;    return s;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;各地时区获取：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;NSDate *nowDate = [NSDate new];&lt;/div&gt;&lt;div&gt;    NSDateFormatter *formatter    =  [[NSDateFormatter alloc] init];&lt;/div&gt;&lt;div&gt;    [formatter    setDateFormat:@&quot;yyyy/MM/dd HH:mm:ss&quot;];&lt;/div&gt;&lt;div&gt;    //    根据时区名字获取当前时间，如果该时区不存在，默认获取系统当前时区的时间&lt;/div&gt;&lt;div&gt;    //    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@&quot;Europe/Andorra&quot;];&lt;/div&gt;&lt;div&gt;    //    [formatter setTimeZone:timeZone];&lt;/div&gt;&lt;div&gt;    //获取所有的时区名字&lt;/div&gt;&lt;div&gt;    NSArray *array = [NSTimeZone knownTimeZoneNames];&lt;/div&gt;&lt;div&gt;    //    NSLog(@&quot;array:%@&quot;,array);&lt;/div&gt;&lt;div&gt;    //for循环&lt;/div&gt;&lt;div&gt;    //    for(int i=0;i&amp;lt;[array count];i++)&lt;/div&gt;&lt;div&gt;    //    {&lt;/div&gt;&lt;div&gt;    //        NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:[array objectAtIndex:i]];&lt;/div&gt;&lt;div&gt;    //        [formatter setTimeZone:timeZone];&lt;/div&gt;&lt;div&gt;    //        NSString *locationTime = [formatter stringFromDate:nowDate];&lt;/div&gt;&lt;div&gt;    //        NSLog(@&quot;时区名字:%@   : 时区当前时间: %@&quot;,[array objectAtIndex:i],locationTime);&lt;/div&gt;&lt;div&gt;    //        //NSLog(@&quot;timezone name is:%@&quot;,[array objectAtIndex:i]);&lt;/div&gt;&lt;div&gt;    //    }&lt;/div&gt;&lt;div&gt;    //快速枚举法&lt;/div&gt;&lt;div&gt;    for(NSString *timeZoneName in array){&lt;/div&gt;&lt;div&gt;        [formatter setTimeZone:[NSTimeZone timeZoneWithName:timeZoneName]];&lt;/div&gt;&lt;div&gt;        NSLog(@&quot;%@,%@&quot;,timeZoneName,[formatter stringFromDate:nowDate]);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [formatter release];&lt;/div&gt;&lt;div&gt;    [nowDate release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; NSCalendar用法：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; -(NSString *) getWeek:(NSDate *) d {&lt;/div&gt;&lt;div&gt;    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];&lt;/div&gt;&lt;div&gt;    unsigned units = NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit | NSWeekdayCalendarUnit;&lt;/div&gt;&lt;div&gt;    NSDateComponents *components = [calendar components:units fromDate:d];&lt;/div&gt;&lt;div&gt;    [calendar release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    switch ([components weekday]) {&lt;/div&gt;&lt;div&gt;        case 2:&lt;/div&gt;&lt;div&gt;            return @&quot;Monday&quot;;&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 3:&lt;/div&gt;&lt;div&gt;            return @&quot;Tuesday&quot;;&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 4:&lt;/div&gt;&lt;div&gt;            return @&quot;Wednesday&quot;;&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 5:&lt;/div&gt;&lt;div&gt;           return @&quot;Thursday&quot;;&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 6:&lt;/div&gt;&lt;div&gt;            return  @&quot;Friday&quot;;&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 7:&lt;/div&gt;&lt;div&gt;            return  @&quot;Saturday&quot;;&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 1:&lt;/div&gt;&lt;div&gt;            return @&quot;Sunday&quot;;&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        default:&lt;/div&gt;&lt;div&gt;            return @&quot;No Week&quot;;&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    // 用components，我们可以读取其他更多的数据。&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;4. 用Get方式读取网络数据：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;将网络数读取为字符串&lt;/div&gt;&lt;div&gt;- (NSString *) getDataByURL:(NSString *) url {&lt;/div&gt;&lt;div&gt;    return [[NSString alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] encoding:NSUTF8StringEncoding];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//读取网络图片&lt;/div&gt;&lt;div&gt;- (UIImage *) getImageByURL:(NSString *) url {&lt;/div&gt;&lt;div&gt;    return [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;多线程&lt;/div&gt;&lt;div&gt;[NSThread detachNewThreadSelector:@selector(scheduleTask) toTarget:self withObject:nil];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) scheduleTask {&lt;/div&gt;&lt;div&gt;    //create a pool&lt;/div&gt;&lt;div&gt;    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //release the pool;&lt;/div&gt;&lt;div&gt;    [pool release];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//如果有参数，则这么使用：&lt;/div&gt;&lt;div&gt;[NSThread detachNewThreadSelector:@selector(scheduleTask:) toTarget:self withObject:[NSDate date]];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) scheduleTask:(NSDate *) mdate {&lt;/div&gt;&lt;div&gt;    //create a pool&lt;/div&gt;&lt;div&gt;    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //release the pool;&lt;/div&gt;&lt;div&gt;    [pool release];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//注意selector里有冒号。&lt;/div&gt;&lt;div&gt;    //在线程里运行主线程里的方法 &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [self performSelectorOnMainThread:@selector(moveToMain) withObject:nil waitUntilDone:FALSE];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;6. 定时器NSTimer用法:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;  // 一个可以自动关闭的Alert窗口&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil&lt;/div&gt;&lt;div&gt;                                                    message:[@&quot;一个可以自动关闭的Alert窗口&quot;&lt;/div&gt;&lt;div&gt;                                                   delegate:nil&lt;/div&gt;&lt;div&gt;                                          cancelButtonTitle:nil //NSLocalizedString(@&quot;OK&quot;, @&quot;OK&quot;)   //取消任何按钮&lt;/div&gt;&lt;div&gt;                                          otherButtonTitles:nil];&lt;/div&gt;&lt;div&gt;    //[alert setBounds:CGRectMake&lt;/div&gt;&lt;div&gt;      (alert.bounds.origin.x, alert.bounds.origin.y,&lt;/div&gt;&lt;div&gt;      alert.bounds.size.width, alert.bounds.size.height+30.0)];&lt;/div&gt;&lt;div&gt;    [alert show];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    // Adjust the indicator so it is up a few pixels from the bottom of the alert&lt;/div&gt;&lt;div&gt;    indicator.center = CGPointMake(alert.bounds.size.width/2,  alert.bounds.size.height-40.0);&lt;/div&gt;&lt;div&gt;    [indicator startAnimating];&lt;/div&gt;&lt;div&gt;    [alert insertSubview:indicator atIndex:0];&lt;/div&gt;&lt;div&gt;    [indicator release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [NSTimer scheduledTimerWithTimeInterval:3.0f&lt;/div&gt;&lt;div&gt;                                     target:self&lt;/div&gt;&lt;div&gt;                                   selector:@selector(dismissAlert:)&lt;/div&gt;&lt;div&gt;                                   userInfo:[NSDictionary dictionaryWithObjectsAndKeys:alert,&lt;/div&gt;&lt;div&gt;                   @&quot;alert&quot;, @&quot;testing &quot;, @&quot;key&quot; ,nil]  //如果不用传递参数，那么可以将此项设置为nil.&lt;/div&gt;&lt;div&gt;                                    repeats:NO];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSLog(@&quot;release alert&quot;);&lt;/div&gt;&lt;div&gt;    [alert release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) dismissAlert:(NSTimer *)timer{&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSLog(@&quot;release timer&quot;);&lt;/div&gt;&lt;div&gt;    NSLog([[timer userInfo]  objectForKey:@&quot;key&quot;]);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    UIAlertView *alert = [[timer userInfo]  objectForKey:@&quot;alert&quot;];&lt;/div&gt;&lt;div&gt;    [alert dismissWithClickedButtonIndex:0 animated:YES];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;定时器停止使用：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;[timer invalidate];&lt;/div&gt;&lt;div&gt;timer = nil;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     7. 用户缺省值NSUserDefaults读取：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //得到用户缺省值&lt;/div&gt;&lt;div&gt;    NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //在缺省值中找到AppleLanguages, 返回值是一个数组&lt;/div&gt;&lt;div&gt;    NSArray* languages = [defs objectForKey:@&quot;AppleLanguages&quot;];&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;all language语言 is %@&quot;, languages);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //在得到的数组中的第一个项就是用户的首选语言了&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;首选语言 is %@&quot;,[languages objectAtIndex:0]);  &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //get the language &amp;amp; country code&lt;/div&gt;&lt;div&gt;    NSLocale *currentLocale = [NSLocale currentLocale];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSLog(@&quot;Language Code is %@&quot;, [currentLocale objectForKey:NSLocaleLanguageCode]);&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;Country Code is %@&quot;, [currentLocale objectForKey:NSLocaleCountryCode&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;8. View之间切换的动态效果设置：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    SettingsController *settings = [[SettingsController alloc]initWithNibName:@&quot;SettingsView&quot; bundle:nil];&lt;/div&gt;&lt;div&gt;    settings.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;  //水平翻转&lt;/div&gt;&lt;div&gt;    [self presentModalViewController:settings animated:YES];&lt;/div&gt;&lt;div&gt;    [settings release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;9.NSScrollView 滑动用法：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) scrollViewDidScroll:(UIScrollView *)scrollView{&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;正在滑动中...&quot;);&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//用户直接滑动NSScrollView，可以看到滑动条&lt;/div&gt;&lt;div&gt;-(void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView {&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;// 通过其他控件触发NSScrollView滑动，看不到滑动条&lt;/div&gt;&lt;div&gt;- (void) scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    11.键盘处理系列&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; //set the UIKeyboard to switch to a different text field when you press return&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//switch textField to the name of your textfield&lt;/div&gt;&lt;div&gt;[textField becomeFirstResponder];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;srandom(time(NULL)); //随机数种子&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;id d = random(); // 随机数&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;   4. iPhone的系统目录:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//得到Document目录：&lt;/div&gt;&lt;div&gt;NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);&lt;/div&gt;&lt;div&gt;NSString *documentsDirectory = [paths objectAtIndex:0];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//得到temp临时目录：&lt;/div&gt;&lt;div&gt;NSString *tempPath = NSTemporaryDirectory();&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//得到目录上的文件地址：&lt;/div&gt;&lt;div&gt;NSString *文件地址 = [目录地址 stringByAppendingPathComponent:@&quot;文件名.扩展名&quot;];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; 5. 状态栏显示Indicator：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  6.app Icon显示数字：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;- (void)applicationDidEnterBackground:(UIApplication *)application{&lt;/div&gt;&lt;div&gt;    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:5];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;   7.sqlite保存地址： &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);&lt;/div&gt;&lt;div&gt;    NSString *thePath = [paths objectAtIndex:0];&lt;/div&gt;&lt;div&gt;    NSString *filePath = [thePath stringByAppendingPathComponent:@&quot;kilonet1.sqlite&quot;];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSString *dbPath = [[[NSBundle mainBundle] resourcePath]&lt;/div&gt;&lt;div&gt;                        stringByAppendingPathComponent:@&quot;kilonet2.sqlite&quot;]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;   8.Application退出：exit(0);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;      9. AlertView，ActionSheet的cancelButton点击事件：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;-(void) actionSheet :(UIActionSheet *) actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {&lt;/div&gt;&lt;div&gt;    NSLog(@&quot;cancel actionSheet........&quot;);&lt;/div&gt;&lt;div&gt;    //当用户按下cancel按钮&lt;/div&gt;&lt;div&gt;    if( buttonIndex == [actionSheet cancelButtonIndex]) {&lt;/div&gt;&lt;div&gt;        exit(0);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;//    //当用户按下destructive按钮&lt;/div&gt;&lt;div&gt;//    if( buttonIndex == [actionSheet destructiveButtonIndex]) {&lt;/div&gt;&lt;div&gt;//        // DoSomething here.&lt;/div&gt;&lt;div&gt;//    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {&lt;/div&gt;&lt;div&gt;     NSLog(@&quot;cancel alertView........&quot;);&lt;/div&gt;&lt;div&gt;    if (buttonIndex == [alertView cancelButtonIndex]) {&lt;/div&gt;&lt;div&gt;        exit(0);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  10.给Window设置全局的背景图片：&lt;/div&gt;&lt;div&gt;window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@&quot;coolblack.png&quot;]];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    11. UITextField文本框显示及对键盘的控制:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;#pragma mark -&lt;/div&gt;&lt;div&gt;#pragma mark UITextFieldDelegate&lt;/div&gt;&lt;div&gt;//控制键盘跳转&lt;/div&gt;&lt;div&gt;- (BOOL)textFieldShouldReturn:(UITextField *)textField {&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    if (textField == _txtAccount) {&lt;/div&gt;&lt;div&gt;        if ([_txtAccount.text length]==0) {&lt;/div&gt;&lt;div&gt;            return NO;&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;        [_txtPassword becomeFirstResponder];&lt;/div&gt;&lt;div&gt;    } else if (textField == _txtPassword) {&lt;/div&gt;&lt;div&gt;        [_txtPassword resignFirstResponder];&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    return YES;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//输入框背景更换&lt;/div&gt;&lt;div&gt;-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField{&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [textField setBackground:[UIImage imageNamed:@&quot;ctext_field_02.png&quot;]];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    return YES;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) textFieldDidEndEditing:(UITextField *)textField{&lt;/div&gt;&lt;div&gt;    [textField setBackground:[UIImage imageNamed:@&quot;ctext_field_01.png&quot;]];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;12.UITextField文本框前面空白宽度设置以及后面组合按钮设置：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;    //给文本输入框后面加入空白&lt;/div&gt;&lt;div&gt;    _txtAccount.rightView = _btnDropDown;&lt;/div&gt;&lt;div&gt;    _txtAccount.rightViewMode =  UITextFieldViewModeAlways;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //给文本输入框前面加入空白&lt;/div&gt;&lt;div&gt;    CGRect frame = [_txtAccount frame];&lt;/div&gt;&lt;div&gt;    frame.size.width = 5;&lt;/div&gt;&lt;div&gt;    UIView *leftview = [[UIView alloc] initWithFrame:frame];&lt;/div&gt;&lt;div&gt;    _txtAccount.leftViewMode = UITextFieldViewModeAlways;&lt;/div&gt;&lt;div&gt;    _txtAccount.leftView = leftview;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  13. UIScrollView 设置滑动不超出本身范围：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; [fcScrollView setBounces:NO]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; 14. 在drawRect里画文字：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     UIFont * f = [UIFont systemFontOfSize:20]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [[UIColor darkGrayColor] set]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSString * text = @&quot;hi \nKiloNet&quot;; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [text drawAtPoint:CGPointMake(center.x,center.y) withFont:f];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    15. NSArray查找是否存在对象时用indexOfObject,如果不存在则返回为NSNotFound.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    16. NString与NSArray之间相互转换：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;array = [string componentsSeparatedByString:@&quot;,&quot;];&lt;/div&gt;&lt;div&gt;string = [[array valueForKey:@&quot;description&quot;] componentsJoinedByString:@&quot;,&quot;];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     17. TabController随意切换tab bar：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;[self.tabBarController setSelectedIndex:tabIndex];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;或者 self.tabBarController.selectedIndex = tabIndex;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;或者实现下面的delegate来扑捉tab bar的事件： &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码-(BOOL) tabBarController:(UITabBarController *)tabBarController&lt;/div&gt;&lt;div&gt;shouldSelectViewController:(UIViewController *)viewController&lt;/div&gt;&lt;div&gt;{        if ([viewController.tabBarItem.title isEqualToString: NSLocalizedString(@&quot;Logout&quot;,nil)])&lt;/div&gt;&lt;div&gt;{        [self showLogout];        return NO;    }    return YES;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    18. 自定义View之间切换动画：&lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;- (void) pushController: (UIViewController*) controller&lt;/div&gt;&lt;div&gt;         withTransition: (UIViewAnimationTransition) transition&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;    [UIView beginAnimations:nil context:NULL];&lt;/div&gt;&lt;div&gt;    [self pushViewController:controller animated:NO];&lt;/div&gt;&lt;div&gt;    [UIView setAnimationDuration:.5];&lt;/div&gt;&lt;div&gt;    [UIView setAnimationBeginsFromCurrentState:YES];&lt;/div&gt;&lt;div&gt;    [UIView setAnimationTransition:transition forView:self.view cache:YES];&lt;/div&gt;&lt;div&gt;    [UIView commitAnimations];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;CATransition *transition = [CATransition animation];&lt;/div&gt;&lt;div&gt;transition.duration = kAnimationDuration;&lt;/div&gt;&lt;div&gt;transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];&lt;/div&gt;&lt;div&gt;transition.type = kCATransitionPush;&lt;/div&gt;&lt;div&gt;transition.subtype = kCATransitionFromTop;&lt;/div&gt;&lt;div&gt;transitioning = YES;&lt;/div&gt;&lt;div&gt;transition.delegate = self;&lt;/div&gt;&lt;div&gt;[self.navigationController.view.layer addAnimation:transition forKey:nil];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;self.navigationController.navigationBarHidden = NO;&lt;/div&gt;&lt;div&gt;[self.navigationController pushViewController:tableViewController animated:YES];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     20.计算字符串长度：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;CGFloat w = [title sizeWithFont:[UIFont fontWithName:@&quot;Arial&quot; size:18]].width; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  23.在使用UISearchBar时，将背景色设定为clearColor，或者将translucent设为YES，都不能使背景透明，经过一番研究，发现了一种超级简单和实用的方法：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;1&lt;/div&gt;&lt;div&gt; [[searchbar.subviews objectAtIndex:0]removeFromSuperview]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;背景完全消除了，只剩下搜索框本身了。 &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  24.  图像与缓存 :&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;UIImageView *wallpaper = [[UIImageView alloc] initWithImage:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;        [UIImage imageNamed:@&quot;icon.png&quot;]]; // 会缓存图片&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;UIImageView *wallpaper = [[UIImageView alloc] initWithImage:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;        [UIImage imageWithContentsOfFile:@&quot;icon.png&quot;]]; // 不会缓存图片 &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  25. iphone-常用的对视图图层(layer)的操作&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;对图层的操作：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;(1.给图层添加背景图片：&lt;/div&gt;&lt;div&gt;myView.layer.contents = (id)[UIImage imageNamed:@&quot;view_BG.png&quot;].CGImage;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;(2.将图层的边框设置为圆脚&lt;/div&gt;&lt;div&gt;myWebView.layer.cornerRadius = 8;&lt;/div&gt;&lt;div&gt;myWebView.layer.masksToBounds = YES;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;(3.给图层添加一个有色边框&lt;/div&gt;&lt;div&gt;myWebView.layer.borderWidth = 5;&lt;/div&gt;&lt;div&gt;myWebView.layer.borderColor = [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;source: &lt;a href=&quot;http://www.codeios.com/forum.php?mod=viewthread&amp;amp;tid=98&amp;amp;page=1&quot;&gt;http://www.codeios.com/forum.php?mod=viewthread&amp;amp;tid=98&amp;amp;page=1&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/785219563319921458/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/785219563319921458' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/785219563319921458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/785219563319921458'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/04/ios.html' title='iOS開發中常用代碼解釋'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-1147633746551826303</id><published>2011-04-22T10:59:00.000-07:00</published><updated>2011-04-22T11:00:29.220-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><title type='text'>關於.NET Framework / ASP.NET這條路</title><content type='html'>.NET Framework歷史版本及功能，第6點是我自己整理。&lt;br /&gt;.NET Framework 1.0&lt;br /&gt;.NET Framework 1.1&lt;br /&gt;.NET Framework 2.0&lt;br /&gt;CLR + Windows forms + Web Services + ASP.NET&lt;br /&gt;.NET Framework 3.0&lt;br /&gt;.NET Framework 2.0 + WCF + WF + WPF + CardSpace&lt;br /&gt;.NET Framework 3.5&lt;br /&gt;.NET Framework 3.0 + LINQ + AJAX + REST&lt;br /&gt;.NET Framework 4.0&lt;br /&gt;.NET Framework 3.5 + Entity Framework + ASP.NET MVC + Parallel&lt;br /&gt;先說結論，再說故事。&lt;br /&gt;&lt;br /&gt;結論&lt;br /&gt;通常第一版都是實驗性質或有很大的改進空間，不管是多好的東西都一樣。從第二版開始，似乎是個不錯的開始。&lt;br /&gt;&lt;br /&gt;故事1--.NET Framework 2.0&lt;br /&gt;&lt;br /&gt;現在的資訊爆炸，但這些資訊你可以不看。但就資訊技術人員而言，技術更新的速度才是一大挑戰，以前一個技術能讓你十年有飯吃，現在一個技術能讓你三年有飯吃就很不錯了，技術更新的速度讓人「怕怕的」，我實在很敬佩那些永遠走在資訊前端的前輩，有著過人的領悟力與學習力。&lt;br /&gt;&lt;br /&gt;話說從前，我是學習Visual Basic 6與ASP，為什學這兩樣？也沒有什麼特別的原因，學校教什麼，我們就學什麼，而且從Visual Basic 6接ASP(VB Script)還很順，所以在使用ASP上還算順手。&lt;br /&gt;&lt;br /&gt;後來，微軟登高一呼：「我們要進入.NET的世界！」然後推出了.NET Framework 1.0，那時的ASP由2.0到3.0，ASP 3.0之後微軟也很明確表示，ASP不再更新維護了，因為微軟要全力推「.NET」這個…產品嗎？概念嗎？程式語言嗎？反正那時候認為是新一代的ASP就是了。&lt;br /&gt;&lt;br /&gt;我還很認真的去買書來看，結果一個月後我就放棄了，那ASP.NET 1.0是什麼鬼東西，看不懂，結果我又回到ASP的身邊，反正工作上也只用的到ASP，會不會ASP.NET也不影響工作。&lt;br /&gt;&lt;br /&gt;一段時間又過去了，突然發現，怎麼大家又在推「ASP.NET 2.0」，而且這一次好像又不一樣了，Survey之後發現，.NET Framework 2.0是個全新的改版，不同於.NET Framework 1.0 / 1.1，而且微軟似乎也發現開發人員的辛苦，承諾未來的改版會使用「積木式」方式來改版，就是說，你學了.NET Framework 2.0的東西，拿到.NET Framework 3.0 / 3.5 / 4.0上一樣都可以使用，讓你不會天天做打掉重練的工作。就是這一點，讓我試著相信它，開始學習著ASP.NET 2.0。&lt;br /&gt;&lt;br /&gt;另外在.NET Framework 2.0還有一項重要事，那就是開發工具的完備，那是在.NET Framework 1.0 / 1.1所沒有的。在.NET Framework 2.0有Visual Studio 2005 / 2008兩個版本，我學ASP.NET 2.0時已經是Visual Studio 2008版本，就Visual Studio 2008來開發ASP.NET 2.0而言，還蠻快樂的。&lt;br /&gt;&lt;br /&gt;[Key Point 1].NET Framework → .NET Framework 2.0&lt;br /&gt;&lt;br /&gt;故事2--LINQ to SQL&lt;br /&gt;&lt;br /&gt;時間飛快，在學習.NET Framework 2.0不久，.NET Framwork 3.0推出，3.0還沒有什麼感覺，又不久之後，馬上再推出.NET Framework 3.5，這個3.5版的推出又是一個高潮 ，因為它提供了幾個重要的元素「LINQ + AJAX + REST」，其中最紅的就是LINQ(Language-Integrated Query)，LINQ是個統稱，內容幾項重要的技術內容LINQ to Object、LINQ to ADO.NET(LINQ to DataSet、LINQ to SQL)、LINQ to XML、LINQ to Entities。&lt;br /&gt;&lt;br /&gt;如果有學LINQ，我相信其中的LINQ to SQL會是你的一項主力。不過，就在2008一篇「Update on LINQ to SQL and LINQ to Entities Roadmap」的微軟官方文章，給所有有學LINQ to SQL的人一顆炸彈，他們的一句「他們會很認真的聽取 LINQ to SQL 社群的聲音，然後好好的來加強我們的 Entity Framework 產品」嚇死了一堆人。&lt;br /&gt;&lt;br /&gt;很明顯，他們將主力放在Entity Framework上面(可看成LINQ to Entities這一項)，那LINQ to SQL呢？在.NET Framework 4.0有做一些錯誤修正，但請注意，他們已經很明顯未來會不斷加強的是Entity Framework，目前在.NET Framework 4.0裡的是Entity Framework 4.0，現在已經有Entity Framework 4.1版本可以下載安裝使用。&lt;br /&gt;&lt;br /&gt;[Key Point 2] LINQ to SQL → LINQ to Entities → Entity Famework&lt;br /&gt;&lt;br /&gt;故事3--Web Service&lt;br /&gt;&lt;br /&gt;在ASP.NET 2.0時，提供了一個很棒的Web Services服務，也就是說，我可以把相關Function透過伺服器分享出來，分享給網路上其他需要的人使用。使用者只要引用我的Web Services，就可以立即擁有我所提供的服務。&lt;br /&gt;&lt;br /&gt;Web Services好是好，但也是有一些問題，所以Microsoft在.NET Framework 3.5又提出了一個 REST，董大偉老師有篇介紹 REST 文章，可以知一二。&lt;br /&gt;&lt;br /&gt;[Key Point 3] Web Service → REST&lt;br /&gt;&lt;br /&gt;故事4-- ASP.NET MVC 2.0&lt;br /&gt;&lt;br /&gt;在Visual Studio 2008 + .NET Framework 3.5時，微軟還推出了一個很重要的Web技術，即ASP.NET MVC 1.0，老實說，ASP.NET MVC 1.0我連碰都沒碰過，但我碰了ASP.NET MVC 2.0。ASP.NET MVC 2.0對我而言，感覺又回到寫ASP，再強調一下，是「感覺」，不是「回到寫ASP」，什麼感覺，是一種「操之在我」的感覺，但靈活度是ASP及ASP.NET完全比不上的感覺。&lt;br /&gt;&lt;br /&gt;ASP.NET Web Form入門而言，實在好學好用，但當你要深入一些時，會發現就沒那怎容易，當你想把你的魔手伸的越深入，你就會發現Web Form的控制項越複雜。但一切一切問題在ASP.NET MVC身上都沒有，因為它根本沒有控制項！&lt;br /&gt;&lt;br /&gt;不過想要學習、使用ASP.NET MVC，就我個人認為，不是件簡單的事，因為有許多觀念必須先行建立，物件導向程式設計、Visual Basic 9/10語法熟悉度、LINQ、.NET Framework Class…這些都會了，再學習ASP.NET MVC會比較輕鬆，不然走一步算一步是比較辛苦點。&lt;br /&gt;&lt;br /&gt;最近，ASP.NET MVC 3又正式推出，在ASP.NET MVC 3裡有一個重點Razor View Engine，Razor是一個新的View Engine，在我們撰寫ASP.NET MVC 3時，它提供了更簡潔的語法。不過馬上就有人指出，使用Razor怪怪的，因為它會破壞MVC的規則，將Controller的內容放到View裡。但Razor也讓我們在撰寫View提供了很好的規範，不會整個畫面裡都是&lt;% ~ %&gt;的符號。&lt;br /&gt;&lt;br /&gt;Razor最早是與另一套微軟免費入門網頁開發軟體WebMatrix所採用，後來可能覺的很不錯，所以在ASP.NET MVC 3.0也加入了Razor的支援。所以到了ASP.NET MVC 3.0你可以選擇使用&lt;% ~ %&gt;的Visual Basic語法，也可以使用Razor的@Code ~ End Code或@ViewData()之類的語法。&lt;br /&gt;&lt;br /&gt;[Key Point 4] ASP.NET MVC 1.0 →  ASP.NET MVC 2.0 / 3.0, Razor View Engine&lt;br /&gt;&lt;br /&gt;整理一下Key Point&lt;br /&gt;&lt;br /&gt;[Key Point 1] .NET Framework 1.0 → .NET Framework 2.0&lt;br /&gt;[Key Point 2] LINQ to SQL → LINQ to Entities&lt;br /&gt;[Key Point 3] Web Services → REST&lt;br /&gt;[Key Point 4] Web Form → ASP.NET MVC&lt;br /&gt;每個技術背景都有故事，在.NET Framework的裡的每個進步，都是為了解決一些前一代的一些問題或提供更好的解決方案。我們不能怪微軟說，為什麼說放就放，說改就改，而是要去思考及了解前因後果，當然不是每件事的回答或解釋都讓開發人員滿意。&lt;br /&gt;&lt;br /&gt;由以上來看，.NET Framework到目前為止，所推出的第一代技術都會被第二代技術替代，其實這是必然的結果，只是改的太兇，苦的是這是程式開發人員。但我們在每一項新技術推出之時，每篇文章、專欄、ABC大會、XYZ研討會…你都只會聽到「優點」，但我在意的是「缺點」呢？例如，這一篇「對Entity Framework Performance 抱怨以及建議」，說明Entity Framework 1.0版實在不怎麼樣，但現在的Entity Framework 4.0到是沒聽到這種聲音了，原因前提過了，Entity Framework是現在的主力。而缺點，通常會在一段時間，實際使用於專案上之後，才會出現。&lt;br /&gt;&lt;br /&gt;如果你現在才要進入.NET Framework的世界，我個人是建議，如果是那種「最新」的技術，有精力再去研究，如果是第二版之後改進的技術，通常是可以上場見世面了。了解每一項技術所提供的優點及缺點，所以當我聽完優點後，會靜一靜，等等看市場上有沒有其他聲音。以上是我個人就我在.NET Framework/ASP.NET的學習上的驗經談。我的時間、精力有限，所以在.NET Framework/ASP.NET這條路，我是選擇走「老二哲學」。&lt;br /&gt;&lt;br /&gt;source: http://kkbruce.blogspot.com/2011/04/net-framework-aspnet.html?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+KingkongBruce+%28KingKong+Bruce%E8%A8%98%E4%BA%8B%29&amp;utm_content=Google+Reader</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/1147633746551826303/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/1147633746551826303' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/1147633746551826303'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/1147633746551826303'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/04/net-framework-aspnet.html' title='關於.NET Framework / ASP.NET這條路'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-8012452799353112292</id><published>2011-02-25T00:01:00.000-08:00</published><updated>2011-02-25T00:02:22.762-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><category scheme="http://www.blogger.com/atom/ns#" term="MSSQL"/><title type='text'>Moving SQL NVarchar to ORACLE NVarchar2</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Geneva, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 12px; &quot;&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;之前用SSIS在做ORACLE與SQL間資料搬移時，最痛恨遇到NVarchar跟Unicode Code問題了。&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;明明是NVarchar(SQL)搬到NVarchar2(ORACLE)，兩邊都Support Unicode，但SSIS都老會要求指定Data Flow Destination的Code Page，接著又會嚷著SQL中得到的Unicode不能直接轉成Non-Unicode，所以就得很可笑地在Nvarchar與NVarchar2兩個Unicode欄位中加上一個Data Conversion。如下圖:&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;&lt;img src=&quot;http://blog.darkthread.net/photos/darkthread/images/775/original.aspx&quot; id=&quot;id4047881723381579&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot; /&gt;&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;不過，苦難還沒有結束... 如果很不幸地，NVarchar中還真的放了Unicode字元，則在轉換時，會出現以下的錯誤訊息。&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;Error: 0xC02020C5 at Data Flow Task Failure Sample, Data Conversion [543]: Data conversion failed while converting column &quot;UnicodeField&quot; (505) to column &quot;UnicodeFieldMapping&quot; (557). &lt;span style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;The conversion returned status value 4 and status text &quot;Text was truncated or one or more characters had no match in the target code page.&quot;.&lt;br /&gt;&lt;/span&gt;Error: 0xC020902A at Data Flow Task Failure Sample, Data Conversion [543]: The &quot;output column &quot;UnicodeFieldMapping&quot; (557)&quot; failed because truncation occurred, and the truncation row disposition on &quot;output column &quot;UnicodeFieldMapping&quot; (557)&quot; specifies failure on truncation. A truncation error occurred on the specified object of the specified component.&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;這問題讓我很困擾，不過因為遇到時都是做些一次性的資料搬移，所以我都很鄉愿地繞路解決(最愛用的一招是回去改用SQL 2000 DTS，很奇怪，用DTS搬資料時，幾乎不曾為Enocding傷過腦筋)，未曾認真與它對決過。&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;最近同事想用SSIS來做重要的日常資料搬移，就卡在這個問題上，由於搬移是每天要跑的，繞路的成本就會高出許多，這回我總算被迫要收服這隻妖怪。東試西試之餘，忽然想到之前使用&lt;a href=&quot;http://blog.darkthread.net/blogs/darkthreadtw/archive/2006/12/28/kb-oracle-9i-nvarchar.aspx&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot;&gt;Query Express&lt;/a&gt;的經驗，Oracle的OLE DB Driver才能正確顯示Unicode，Microsft的OLE DB for Oracle反而不行，所以我試著把Data Flow Destination的OLE DB換成Oracle版。&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;美妙的事出現了!!  使用Oracle Provider for OLE DB後，連Data Conversion都不用了，直接對Unicode對Unicode，一次搞定。&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;&lt;img src=&quot;http://blog.darkthread.net/photos/darkthread/images/774/original.aspx&quot; id=&quot;id693252686643973&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot; /&gt;&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;看一下令人興奮的結果，SQL裡的六頭牛被搬到ORACLE裡了，NVarchar --&gt; NVarchar2，萬牛奔騰的感覺豈是一個爽字可以形容，哈!!&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;&lt;img src=&quot;http://blog.darkthread.net/photos/darkthread/images/773/original.aspx&quot; id=&quot;id08236012165434659&quot; style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; &quot; /&gt;&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; &quot;&gt;source: &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Georgia, serif; line-height: normal; font-size: 16px; &quot;&gt;&lt;a href=&quot;http://blog.darkthread.net/post-2007-05-17-kb-ssis-moving-sql-nvarchar-to-oracle-nvarchar2.aspx&quot;&gt;http://blog.darkthread.net/post-2007-05-17-kb-ssis-moving-sql-nvarchar-to-oracle-nvarchar2.aspx&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/8012452799353112292/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/8012452799353112292' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/8012452799353112292'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/8012452799353112292'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/02/moving-sql-nvarchar-to-oracle-nvarchar2.html' title='Moving SQL NVarchar to ORACLE NVarchar2'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-5611205603121089424</id><published>2011-02-19T06:53:00.000-08:00</published><updated>2011-02-19T06:55:07.939-08:00</updated><title type='text'>Google App Engine for Java下的URL編碼轉換問題</title><content type='html'>&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt; &lt;meta equiv=&quot;Content-Style-Type&quot; content=&quot;text/css&quot;&gt; &lt;title&gt;&lt;/title&gt; &lt;meta name=&quot;Generator&quot; content=&quot;Cocoa HTML Writer&quot;&gt; &lt;meta name=&quot;CocoaVersion&quot; content=&quot;1038.35&quot;&gt; &lt;style type=&quot;text/css&quot;&gt; p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana} &lt;/style&gt;   &lt;p class=&quot;p1&quot;&gt;&lt;b&gt;URL编码问题&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt; &lt;meta equiv=&quot;Content-Style-Type&quot; content=&quot;text/css&quot;&gt; &lt;title&gt;&lt;/title&gt; &lt;meta name=&quot;Generator&quot; content=&quot;Cocoa HTML Writer&quot;&gt; &lt;meta name=&quot;CocoaVersion&quot; content=&quot;1038.35&quot;&gt; &lt;style type=&quot;text/css&quot;&gt; p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #333233} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #0166aa} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #333233; min-height: 16.0px} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #333300} p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana} p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Courier; color: #333233} p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 19.0px &#39;Comic Sans MS&#39;} p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; text-align: right; line-height: 19.0px; font: 12.0px Courier} p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 16.0px Courier} p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 16.0px &#39;Times New Roman&#39;} p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px &#39;Courier New&#39;; background-color: #f5f5f5} p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; text-align: right; line-height: 19.0px; font: 12.0px Courier; color: #333233} p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Courier; color: #0166aa} li.li2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #0166aa} span.s1 {color: #333233} span.s2 {color: #0166aa} span.s3 {font: 16.0px &#39;Times New Roman&#39;} span.s4 {color: #00807f} span.s5 {font: 13.0px Courier; color: #0166aa} span.s6 {font: 13.0px Verdana; color: #333233} span.s7 {font: 13.0px Verdana} table.t1 {width: 776.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td1 {width: 774.0px; background-color: #ccccff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td2 {width: 161.0px; background-color: #ffffff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td3 {width: 611.0px; background-color: #ffffff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td4 {width: 91.0px; background-color: #ffffff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td5 {width: 681.0px; background-color: #ffffff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} ul.ul1 {list-style-type: disc} &lt;/style&gt;   &lt;p class=&quot;p1&quot;&gt;此部分参考英文资料：&lt;/p&gt; &lt;ul class=&quot;ul1&quot;&gt; &lt;li class=&quot;li2&quot;&gt;&lt;a href=&quot;http://www.blooberry.com/indexdot/html/topics/urlencoding.htm&quot;&gt;http://www.blooberry.com/indexdot/html/topics/urlencoding.htm&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;li2&quot;&gt;&lt;a href=&quot;http://www.w3schools.com/TAGS/ref_urlencode.asp&quot;&gt;http://www.w3schools.com/TAGS/ref_urlencode.asp&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;li2&quot;&gt;&lt;a href=&quot;http://www.rfc-editor.org/rfc/rfc2396.txt&quot;&gt;http://www.rfc-editor.org/rfc/rfc2396.txt&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p class=&quot;p1&quot;&gt;在HTTP客户端使用get方法通过URL向服务器发送参数里，由于URL里面只可以包含允许的字符（也称为合法字符），所以一旦参数里面存在非法字符，就必须通过某种手段对其进行合法化转换，在服务器端再将其转换回来，&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;在RFC1738：Uniform Resource Locators (URL) 规范中，指出URL只能包含AscII集中的一个子集中的字符，这个子集也称作AscII character-set，原文写道：&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;&lt;i&gt;&quot;...Only alphanumerics [0-9a-zA-Z], the special characters &quot;$-_.+!*&#39;(),&quot; &lt;/i&gt;&lt;b&gt;&lt;i&gt;[not including the quotes - ed]&lt;/i&gt;&lt;/b&gt;&lt;i&gt;, and reserved characters used for their reserved purposes may be used unencoded within a URL.&quot;&lt;/i&gt;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;实际上URL规范中，字符包括保留字符，非保留字符两种，RFC2396中定义了URL中的保留(reserved)字符为：&lt;/p&gt; &lt;p class=&quot;p3&quot;&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;Reserved&lt;/p&gt; &lt;p class=&quot;p4&quot;&gt;reserved    = &quot;;&quot; | &quot;/&quot; | &quot;?&quot; | &quot;:&quot; | &quot;@&quot; | &quot;&amp;amp;&quot; | &quot;=&quot; | &quot;+&quot; |&lt;/p&gt; &lt;p class=&quot;p4&quot;&gt;                    &quot;$&quot; | &quot;,&quot;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;非保留字符为：&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;Unreserved&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;unreserved  = alphanum | mark&lt;/p&gt; &lt;p class=&quot;p3&quot;&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;      mark        = &quot;-&quot; | &quot;_&quot; | &quot;.&quot; | &quot;!&quot; | &quot;~&quot; | &quot;*&quot; | &quot;&#39;&quot; | &quot;(&quot; | &quot;)&quot;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt; &lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;实际上非保留字符就是AscII character-set，此集合之外的字符都被称为非法字符（invalid character)或不安全字符(unsafe character)，这些字符都将被编码转换为合法字符(valid character)或叫安全字符(safe charactor)，转换的动作在英文常表示为escape。&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;escape的方式如下规范中所述：&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt; &lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;Escaped Encoding&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;An escaped octet is encoded as a character triplet, consisting of the&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;   percent character &quot;%&quot; followed by the two hexadecimal digits&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;   representing the octet code. For example, &quot;%20&quot; is the escaped&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;   encoding for the US-ASCII space character.&lt;/p&gt; &lt;p class=&quot;p3&quot;&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;      escaped     = &quot;%&quot; hex hex&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;      hex         = digit | &quot;A&quot; | &quot;B&quot; | &quot;C&quot; | &quot;D&quot; | &quot;E&quot; | &quot;F&quot; |&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;                            &quot;a&quot; | &quot;b&quot; | &quot;c&quot; | &quot;d&quot; | &quot;e&quot; | &quot;f&quot;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt; &lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;转换时使用的字符集为ISO-8859-1也称为ISO-Latin或Latin-1，注意不是Unicode，这就引起了新的问题，对于不在ISO-Latin中的符号，就没有一个安全的途径进行编码，因为根据RFC2396（注意这是URI规范，但是对URL适用，因为URL是URI的子集，有兴趣的读者请查阅URL和URI之间的关系），URL里还无法指定自定义的字符集(比如UTF-8)。&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;虽然根据标准，在URL中我们无法使用非ISO-Latin字符集以外的字符，但是在现实中，为了解决实际问题，大家都有事实上的标准那就是Unicode编码，现行的为UTF-8，现在浏览器都支持UTF-8的URL编码转换，当然，这个时候的转换动作不再叫escape，而是称为URIEncode。另外，UTF-8与Latin-1是兼容的，相关的信息可参考：&lt;/p&gt; &lt;ul class=&quot;ul1&quot;&gt; &lt;li class=&quot;li2&quot;&gt;&lt;a href=&quot;http://www.stanford.edu/~laurik/fsmbook/faq/utf8.html&quot;&gt;http://www.stanford.edu/~laurik/fsmbook/faq/utf8.html&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;li2&quot;&gt;&lt;a href=&quot;http://baike.baidu.com/view/25412.htm&quot;&gt;http://baike.baidu.com/view/25412.htm&lt;/a&gt;&lt;/li&gt; &lt;li class=&quot;li2&quot;&gt;&lt;a href=&quot;http://www.permadi.com/tutorial/urlEncoding/&quot;&gt;http://www.permadi.com/tutorial/urlEncoding/&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;PHP与Javascript相关的URIEncode操作请参见：&lt;a href=&quot;http://blog.verymore.com/show-989-1.html&quot;&gt;&lt;span class=&quot;s2&quot;&gt;http://blog.verymore.com/show-989-1.html&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;p5&quot;&gt;&lt;b&gt;GWT的URL编码与解码&lt;/b&gt;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;使用URL类中的静态方法URL.decode 和 URL.encode来进行。&lt;/p&gt; &lt;p class=&quot;p6&quot;&gt;java.lang.Object&lt;/p&gt; &lt;p class=&quot;p6&quot;&gt;  &lt;b&gt;com.google.gwt.http.client.URL&lt;/b&gt; &lt;/p&gt; &lt;table width=&quot;776.0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;t1&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td colspan=&quot;2&quot; valign=&quot;middle&quot; class=&quot;td1&quot;&gt; &lt;p class=&quot;p7&quot;&gt;&lt;b&gt;Method Summary&lt;/b&gt;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; class=&quot;td2&quot;&gt; &lt;p class=&quot;p8&quot;&gt;static java.lang.String&lt;/p&gt; &lt;/td&gt; &lt;td valign=&quot;middle&quot; class=&quot;td3&quot;&gt; &lt;p class=&quot;p9&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;a href=&quot;http://www.cnblogs.com/com/google/gwt/http/client/URL.html#decode(java.lang.String)&quot;&gt;&lt;b&gt;decode&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;(java.lang.String encodedURL)&lt;span class=&quot;s3&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;p10&quot;&gt;          Returns a string where all URL escape sequences have been converted back to their original character representations.&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; class=&quot;td2&quot;&gt; &lt;p class=&quot;p8&quot;&gt;static java.lang.String&lt;/p&gt; &lt;/td&gt; &lt;td valign=&quot;middle&quot; class=&quot;td3&quot;&gt; &lt;p class=&quot;p9&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;a href=&quot;http://www.cnblogs.com/com/google/gwt/http/client/URL.html#decodeComponent(java.lang.String)&quot;&gt;&lt;b&gt;decodeComponent&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;(java.lang.String encodedURLComponent)&lt;span class=&quot;s3&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;p10&quot;&gt;          Returns a string where all URL component escape sequences have been converted back to their original character representations.&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; class=&quot;td2&quot;&gt; &lt;p class=&quot;p8&quot;&gt;static java.lang.String&lt;/p&gt; &lt;/td&gt; &lt;td valign=&quot;middle&quot; class=&quot;td3&quot;&gt; &lt;p class=&quot;p9&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;a href=&quot;http://www.cnblogs.com/com/google/gwt/http/client/URL.html#encode(java.lang.String)&quot;&gt;&lt;b&gt;encode&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;(java.lang.String decodedURL)&lt;span class=&quot;s3&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;p10&quot;&gt;          Returns a string where all characters that are not valid for a complete URL have been escaped.&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; class=&quot;td2&quot;&gt; &lt;p class=&quot;p8&quot;&gt;static java.lang.String&lt;/p&gt; &lt;/td&gt; &lt;td valign=&quot;middle&quot; class=&quot;td3&quot;&gt; &lt;p class=&quot;p9&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;a href=&quot;http://www.cnblogs.com/com/google/gwt/http/client/URL.html#encodeComponent(java.lang.String)&quot;&gt;&lt;b&gt;encodeComponent&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;(java.lang.String decodedURLComponent)&lt;span class=&quot;s3&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;p10&quot;&gt;          Returns a string where all characters that are not valid for a URL component have been escaped.&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p class=&quot;p5&quot;&gt;&lt;b&gt;GAE4Java的编码与解码&lt;/b&gt;&lt;/p&gt; &lt;p class=&quot;p2&quot;&gt;&lt;span class=&quot;s1&quot;&gt;实际上，由于写本文的初衷是作者在这个环境下开发程序时想理清这个问题，所以将服务器环境定位为GAE，实际上就是Java下的URL编码问题，可以参考：&lt;a href=&quot;http://china.manufacturer.com/article/study_for_character_encoding_java.htm&quot;&gt;&lt;span class=&quot;s2&quot;&gt;http://china.manufacturer.com/article/study_for_character_encoding_java.htm&lt;/span&gt;&lt;/a&gt;。&lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;Java中URI Encoding的相关类为URLEncoder，URLDecoder&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;示例：&lt;/p&gt; &lt;p class=&quot;p11&quot;&gt;&lt;span class=&quot;s4&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt; &lt;/span&gt;String text = java.net.URLEncoder.encode(&quot;编码转换&quot;, &quot;utf-8&quot;);&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt; &lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;&lt;span class=&quot;s2&quot;&gt;&lt;a href=&quot;http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/lang/Object.html&quot;&gt;java.lang.Object&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;b&gt;java.net.URLEncoder&lt;/b&gt;&lt;/p&gt; &lt;p class=&quot;p3&quot;&gt;&lt;br /&gt;&lt;/p&gt; &lt;table width=&quot;776.0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;t1&quot;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td colspan=&quot;2&quot; valign=&quot;middle&quot; class=&quot;td1&quot;&gt; &lt;p class=&quot;p7&quot;&gt;&lt;b&gt;Method Summary&lt;/b&gt;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign=&quot;top&quot; class=&quot;td4&quot;&gt; &lt;p class=&quot;p12&quot;&gt;static &lt;a href=&quot;http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/lang/String.html&quot;&gt;&lt;span class=&quot;s2&quot;&gt;String&lt;/span&gt;&lt;/a&gt;&lt;/p&gt; &lt;/td&gt; &lt;td valign=&quot;middle&quot; class=&quot;td5&quot;&gt; &lt;p class=&quot;p13&quot;&gt;&lt;a href=&quot;http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/net/URLEncoder.html#encode(java.lang.String,%20java.lang.String)&quot;&gt;&lt;b&gt;encode&lt;/b&gt;&lt;/a&gt;&lt;span class=&quot;s1&quot;&gt;(&lt;a href=&quot;http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/lang/String.html&quot;&gt;&lt;span class=&quot;s5&quot;&gt;String&lt;/span&gt;&lt;/a&gt; s, &lt;a href=&quot;http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/lang/String.html&quot;&gt;&lt;span class=&quot;s5&quot;&gt;String&lt;/span&gt;&lt;/a&gt; enc)&lt;/span&gt;&lt;span class=&quot;s6&quot;&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class=&quot;p6&quot;&gt;&lt;span class=&quot;s7&quot;&gt;          使用指定的编码机制将字符串转换为 &lt;/span&gt;application/x-www-form-urlencoded&lt;span class=&quot;s7&quot;&gt; 格式。&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p class=&quot;p3&quot;&gt;&lt;br /&gt;&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;URLDecoder此处略去，同上。&lt;/p&gt; &lt;p class=&quot;p1&quot;&gt;【完】&lt;/p&gt;&lt;/div&gt;source: &lt;div&gt;http://www.cnblogs.com/dengfanxin/archive/2009/04/16/GAE_UrlEncoding.html&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/5611205603121089424/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/5611205603121089424' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5611205603121089424'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/5611205603121089424'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/02/google-app-engine-for-javaurl.html' title='Google App Engine for Java下的URL編碼轉換問題'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-2251310430432806959</id><published>2011-02-15T19:01:00.000-08:00</published><updated>2011-02-15T19:02:30.404-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>房产地图google map的初步应用点滴.1)</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17px; &quot;&gt;以前的房产地图一直都是使用有道地图，虽然有道地图是很好，但是为了更好，还是决定使用google地图来重新开发^_^，下面是一个开发完毕的简单应用http://xf.house.163.com/gz/map/000B.html&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;1)整合Google Maps JavaScript API V3 与 Google Local Search API&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Google Maps JavaScript API V3 &lt;/strong&gt;&lt;br /&gt;地址 http://code.google.com/intl/zh-CN/apis/maps/documentation/javascript/&lt;br /&gt;&lt;br /&gt;Google Maps JavaScript API V3 文档读起来真的是很清晰，各种demo也很齐全，并且论坛的拥有巨大的论坛支持，对比了一下Google Maps JavaScript API V3 和 V2 的版本，虽然第3版的 Google Maps API 看上去跟第2版挺相识，但在内在机制上有了较大的变化，尤其在对移动浏览器的支持上，专门针对iphone和android设备的开发。V2版本google已经宣布不再予以继续支持，所以还是选择了V3版本。&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Google Local Search API&lt;/strong&gt;&lt;br /&gt;地址 http://code.google.com/intl/zh-CN/apis/maps/documentation/localsearch/index.html&lt;br /&gt;&lt;br /&gt;上面的地址是目前Local Search的最新地址，但郁闷的是居然挂上了 Deprecated ，一样的文档也相当齐全，在应用之前需要先为你的域名申请一个API key，这个是注册地址http://code.google.com/intl/zh-CN/apis/maps/signup.html，很简单，按照提示很快就搞定了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;在整合Google Maps JavaScript API V3和Google Local Search API发现这两个版本是不兼容的，Local Search API实际上还是沿用了Maps V2的接口，为了解决这个问题，需要中间一个跳板使得两者兼容，所以选择了iframe，父页面使用Google Maps V3，子页面使用Local Search API，当需要应用到本地搜索时，父页面向子页面传递查询条件，子窗口应用Local Search API获得查询的result后返回给父页面，这样就形成一个跳板，避免了两者因为版本问题而产生的冲突，当然还有其他的办法，不过iframe应该是比较简单处理，下面是一个demo&lt;br /&gt;&lt;br /&gt;&lt;img alt=&quot;&quot; src=&quot;http://www.blogjava.net/images/blogjava_net/dongbule/map/map1.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;父页面 : 使用的是Google Maps JavaScript API V3，http://maps.google.com/maps/api/js 网址指向 Javascript 文件所在的位置，该文件会载入使用第 3 版 Google Maps API 所需的全部符号和定义。&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;background-color: rgb(238, 238, 238); font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); padding-top: 4px; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; width: 629px; &quot;&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;!&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 255); &quot;&gt;DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;html &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;xmlns&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;head&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;meta &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;content-type&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; content&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;text/html; charset=GBK&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;/&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;title&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;Google AJAX Search API Sample&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;title&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;style &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;type&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;text/css&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(128, 0, 0); &quot;&gt;&lt;br /&gt;@import url(&quot;http://www.google.com/uds/css/gsearch.css&quot;);&lt;br /&gt;@import url(&quot;http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css&quot;);&lt;br /&gt;@import url(&quot;http://www.google.com/uds/css/gsearch.css&quot;);&lt;br /&gt;@import url(&quot;http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css&quot;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;style&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;type&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;text/javascript&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; src&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;http://xf.house.163.com/product/js/jquery.js&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;type&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;text/javascript&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; src&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;http://maps.google.com/maps/api/js?sensor=false&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;type&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;text/javascript&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; map;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; lat &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;23.116193&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; lng &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;113.374525&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; markersArray &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; [];&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; windowArray &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; [];&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; initialize() {&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; mapDiv &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; document.getElementById(&#39;map&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;-&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;canvas&#39;);&lt;br /&gt;          map &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; google.maps.Map(mapDiv, {&lt;br /&gt;          center: &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; google.maps.LatLng(lat,lng),&lt;br /&gt;          zoom: &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;15&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;,&lt;br /&gt;          mapTypeId: google.maps.MapTypeId.ROADMAP&lt;br /&gt;        });&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;删除叠加层&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; deleteOverlays() {&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;if&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; (markersArray) {&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;for&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; (i &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;in&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; markersArray) {&lt;br /&gt;              markersArray[i].setMap(&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;null&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;            }&lt;br /&gt;            markersArray.length &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;0&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;关闭信息提示窗口&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; closeWindows() {&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;if&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; (windowArray) {&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;for&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; (i &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;in&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; windowArray) {&lt;br /&gt;                windowArray[i].close();&lt;br /&gt;            }&lt;br /&gt;          }&lt;br /&gt;         }&lt;br /&gt;     &lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; show(results){&lt;br /&gt;          parent.deleteOverlays();&lt;br /&gt;          windowArray.length &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;0&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;;&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;for&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; (&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; i &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;0&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;; results &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; i &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; results.length; i&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;++&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;) {&lt;br /&gt;              showOne(results[i]);&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; showOne(result){&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;console.debug(result.title+&quot;,&quot;+result.lat+&quot;:&quot; + result.lng +&quot;,&quot;+result.streetAddress+&quot;,&quot;+result.city+&quot;,&quot;+result.url);&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;          &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; infowindow &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; google.maps.InfoWindow({&lt;br /&gt;              content: result.html&lt;br /&gt;            });&lt;br /&gt;            &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; marker &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; google.maps.Marker({&lt;br /&gt;                position: &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; google.maps.LatLng(result.lat,result.lng),&lt;br /&gt;              map: map&lt;br /&gt;            });&lt;br /&gt;            markersArray.push(marker);&lt;br /&gt;            windowArray.push(infowindow);&lt;br /&gt;            google.maps.event.addListener(marker, &#39;click&#39;, &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;() {&lt;br /&gt;              closeWindows();&lt;br /&gt;                infowindow.open(map,marker);&lt;br /&gt;            });&lt;br /&gt;      }&lt;br /&gt;      &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; searchMap(){&lt;br /&gt;          &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; keyWord &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; document.getElementById(&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;keyWord&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;).value;&lt;br /&gt;          mapIframe.window.loadMap(&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;23.116193&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;,&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;113.374525&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;,keyWord);&lt;br /&gt;      }&lt;br /&gt;      google.maps.event.addDomListener(window, &#39;load&#39;, initialize);&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;head&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;body &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;style&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;div &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;id&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;map-canvas&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; style&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;width: 600px; height: 500px&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;div&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;input &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;type&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;text&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; name&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;keyWord&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; id&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;keyWord&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;/&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;input &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;type&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;button&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; onclick&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;searchMap();&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; value&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;查询&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; id&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;btn&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;/&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); &quot;&gt;&lt;!--&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); &quot;&gt; 子页面 &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); &quot;&gt;--&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;iframe &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;name&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;mapIframe&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; id&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;mapIframe&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; style&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;display:none&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; src&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;local.html&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;iframe&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;body&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;html&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;子页面：http://www.google.com/jsapi?key 需要在google进行申请与域名绑定&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;background-color: rgb(238, 238, 238); font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); padding-top: 4px; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; width: 629px; &quot;&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;!&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 255); &quot;&gt;DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;html &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;xmlns&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;http://www.w3.org/1999/xhtml&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;head&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;meta &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;http-equiv&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;content-type&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; content&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;text/html; charset=GBK&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;/&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); &quot;&gt;&lt;!--&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); &quot;&gt; 此api key为域名163.com &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); &quot;&gt;--&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;src&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;http://www.google.com/jsapi?key=ABQIAAAAtV_DTJOYJT-9cvTO-5KJ2BSnjw5qeDlzCnItJoREFggHbBwu_RQBEyFqvq_vMlzqsS4afIB8ZIvMkw&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt; type&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;text/javascript&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); &quot;&gt;type&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;=&quot;text/javascript&quot;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;    google.load(&#39;search&#39;, &#39;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;1&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;&#39;);&lt;br /&gt;    google.load(&#39;maps&#39;, &#39;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;2&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;&#39;);&lt;br /&gt;&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; loadMap(lat,lng,keyWord) {&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; point &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; GLatLng(lat,lng);&lt;br /&gt;        searchMap(point,keyWord);&lt;br /&gt;    }&lt;br /&gt;       &lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; searchMap(point,keyWord){&lt;br /&gt;        &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;var&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; searcher &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;=&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;new&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt; google.search.LocalSearch();&lt;br /&gt;        searcher.setCenterPoint(point);&lt;br /&gt;        searcher.setResultSetSize(&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;8&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;);&lt;br /&gt;    &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;//&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;searcher.setRestriction(google.search.Search.RESTRICT_TYPE, google.search.LocalSearch.TYPE_KMLONLY_RESULTS)&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;        searcher.setSearchCompleteCallback(&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;this&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;, &lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); &quot;&gt;function&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); &quot;&gt;() {&lt;br /&gt;          parent.MapApi.showSearch_Markers(searcher.results,keyWord);&lt;br /&gt;        });&lt;br /&gt;        searcher.execute(keyWord);&lt;br /&gt;    }&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;script&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;head&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;body&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;body&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&lt;/&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); &quot;&gt;html&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); &quot;&gt;&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;摘录几个常用的Local Search API Reference&lt;br /&gt;&lt;br /&gt;new google.search.LocalSearch() : 创建了一个LocalSearch的Service&lt;br /&gt;&lt;br /&gt;searcher.setCenterPoint(point) : 它接受单一变量，该变量可以是字符串、google.maps.Map2 或google.maps.LatLng。如果是字符串，会尝试将字符串解析为 google.maps.LatLng&lt;br /&gt;&lt;br /&gt;searcher.setResultSetSize(8) : 调用此方法以选择由每个搜索器返回的结果数&lt;br /&gt;&lt;br /&gt;searcher.setRestriction() : 设置搜索结构类型&lt;br /&gt;&lt;br /&gt;searcher.setSearchCompleteCallback() :　此方法用于注册对象和方法以通知搜索完成。应用程序可以通过使用 opt_arguments之后随意传入环境参数&lt;br /&gt;&lt;br /&gt;searcher.execute(keyWord) :  调用此方法以开始新的搜索　&lt;br /&gt;&lt;br /&gt;第一步解决了map和local search的版本冲突后，下面可以进行全部的开发，Google Maps JavaScript API提供的UI，EVENT相关接口非常之多，但不一定就能直接适用我们的需求，还需要使用继承基类MVCObject，OverlayView等继续封装。&lt;/span&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17px; &quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17px; &quot;&gt;source: &lt;a href=&quot;http://www.blogjava.net/dongbule/archive/2011/02/12/344141.html&quot;&gt;http://www.blogjava.net/dongbule/archive/2011/02/12/344141.html&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/2251310430432806959/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/2251310430432806959' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/2251310430432806959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/2251310430432806959'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/02/google-map1.html' title='房产地图google map的初步应用点滴.1)'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-8653704541913456183</id><published>2011-01-11T18:25:00.000-08:00</published><updated>2011-01-11T18:27:14.873-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><title type='text'>Oracle migrate to MySQL</title><content type='html'>一、從Oracle移植到MySQL主要有六個方面的內容需要移植，一是表Table，包括表結構和數據，二是觸發器Trigger，三是存儲過程Procedure，函數function和包Package，四是任務Job ，五是用戶等其他方面的移植，六是具體應用程序通過SQL語句訪問時的細節差異克服。筆者用來移植測試的數據庫是：Oracle 9i ，MySQL 6.0，Windows 2000環境。 &lt;br /&gt;&lt;br /&gt;二、經過映射轉換，比如number會轉換為double，date轉換為timestamp等，請小心處理日期字段的默認值等，表的主鍵，表的索引(Oracle的位圖索引會被轉成BTree索引，另外表和字段的註釋會丟失)等信息。需要特別注意的是，Oracle的自增字段的處理。提供字段自增屬性。 &lt;br /&gt;三、觸發器的移植首先，MySQL在6.0以後才支持觸發器！觸發器的移植沒有現成工具，因為兩者之間的語法差異較大，您只能通過手工對照著原來的邏輯一個一個添加。 &lt;br /&gt;四、存儲過程，函數和程序包的移植程序包是Oracle用來組織邏輯功能的一個Object，MySQL不支持，因此需要將包裡的存儲過程﹑函數等全部放到該數據庫公有過程和函數里面。 &lt;br /&gt;&lt;br /&gt;五、Job的移植Job是Oracle的定時任務實現的方法，MySQL6中用Event實現，具體語法請參考MySQL手冊。 &lt;br /&gt;&lt;br /&gt;六、用戶的移植Oracle的用戶管理和MySQL下有較大區別，請分別建立用戶，並賦予合適的權限。 &lt;br /&gt;&lt;br /&gt;七、應用程序的移植由於語法細節上的差異，導致很多SQL語句需要改寫。筆者記下了所有移植過程中碰到的SQL語句細節差異,列出來以供參考： &lt;br /&gt;1）Oracle的to_char函數不能再使用，換用如CONCAT(14.3)的形式，為了提高應用程序兼容性，建議手工寫一個 &lt;br /&gt;2）Oracle的to_date函數不能再使用，建議手工寫一個添加到MySQL數據庫 &lt;br /&gt;   eg: &lt;br /&gt;to_char(sysdate,&#39;yyyy-mm-dd&#39;)--&gt;date_format(sysdate(),&#39;%Y-%m-%d&#39;); &lt;br /&gt;to_date(sysdate,&#39;yyyy-mm-dd&#39;)--&gt;STR_TO_DATE(sysdate(),&#39;%Y-%m-%d&#39;); &lt;br /&gt;to_char(add_months(to_date (&#39;20000101&#39;,&#39;yyyymmdd&#39;),1),&#39;yyyy-mm-dd&#39;)--&gt;date_add(&#39;2000-01-01&#39;,interval 1 month); &lt;br /&gt;&lt;br /&gt;3）Oracle的decode函數不能再使用，換用SELECT CASE 1 WHEN 1 THEN &#39;one&#39; WHEN 2 THEN &#39;two&#39; ELSE &#39;more&#39; END 的形式 &lt;br /&gt;4)nvl這樣的一些專用函數，MySQL是沒有的，可以把select nvl(to_char(num),&#39;nothing&#39;) from t_equipment轉換成select case num when num then num else &#39;nothing&#39; end from t_equipment &lt;br /&gt;5）instr之類的函數，函數名相同，但參數個數不同 &lt;br /&gt;6）Oracle的sysdate要寫成sysdate()的形式 &lt;br /&gt;7）包的形式已經取消，所以原來以包的方式調用的過程如xx_pack.xxx要寫成xxx() &lt;br /&gt;8）帶進製字符轉數字Oracle風格：TO_NUMBER(strTmp,&#39;XX&#39;) TO_NUMBER（&#39;9&#39;）MySQL風格：CONV(strTmp,16,10) CONV(&#39;9&#39;,10,10) 如果字符串前後有加減操作，會隱含轉換成數字 &lt;br /&gt;9) 不能再有直接調用序列的形式，如果一定需要，可以模擬實現一個 &lt;br /&gt;10）日期直接加減的含義不同了，比如Oracle中sysdate + 1 變成了sysdate() + interval 1 day（注意如果寫成sysdate() + 1 語法還是正確的，但含義是錯誤的）查詢select sysdate() + 1 from dual 在MySQL得到比如20080223153234（= 20080223153233 + 1）的數而在Oracle中會得到第二天當前時刻。 &lt;br /&gt;11) MySQL單純的date類型只是日期不帶時間，DATETIME或TIMESTAMP帶有時間，用DATE_FORMAT函數可以控制顯示形式 &lt;br /&gt;12）select &#39;abc&#39; || &#39;d&#39; from dual 兩個數據執行的結果不同（語法都能通過），MySQL要寫成select concat(&#39;abc&#39; , &#39;d&#39;)的形式 &lt;br /&gt;13) Oracle高級功能，如帶有暗示索引的select語句，MySQL是不支持的（語法可以通過） &lt;br /&gt;14）有些MySQL的保留字不能直接用在SQL語句裡,要加表名或別名限制，如select RIGHT FROM XX要改成select a.RIGHT FROM XX a &lt;br /&gt;15) Oracle的子查詢可以不起別名，但MySQL是必須的，比如下面的別名aa：select field1 from (select sysdate() as field1 from dual) as aa &lt;br /&gt;16）很多系統表名都是不同的,比如，列出某個表的信息：select * from tab where TName=&#39;T_TEST&#39;改成select table_name,table_type from information_schema.tables where table_schema = &#39;user&#39; and table_name= &#39; T_TEST &#39; &lt;br /&gt;17）MySQL下update時不能有本身的子查詢update T_TEST set Flag = 0 where field1 in &lt;br /&gt;(select distinct b.field1 from T_TEST b where b.flag=1) &lt;br /&gt;18）Oracle下&#39;&#39;和null等價，而MySQL則不然select 1 from dual where &#39;&#39; is null在Oracle下可以取到記錄，在MySQL下不能dual表的使用，substr、trim等函數的主要使用方式和Oracle類似 &lt;br /&gt;&lt;br /&gt;八、小結和建議看起來，Oracle移植到MySQL似乎挺麻煩，有沒有一鍵完成的簡單辦法？呵呵，我沒有找到，除非您只使用基本表，只使用基本SQL語句訪問它。&lt;br /&gt;&lt;br /&gt;source: http://shshy39.javaeye.com/blog/342512</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/8653704541913456183/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/8653704541913456183' title='1 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/8653704541913456183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/8653704541913456183'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/01/oracle-migrate-to-mysql.html' title='Oracle migrate to MySQL'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-6834962383505993516</id><published>2011-01-06T18:47:00.000-08:00</published><updated>2011-01-06T19:07:21.393-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><title type='text'>ORA-00031: session marked for kill 處理Oracle中殺不掉的鎖</title><content type='html'>一些ORACLE中的進程被殺掉後，狀態被置為&quot;killed&quot;，但是鎖定的資源很長時間不釋放，有時實在沒辦法，只好重啟數據庫。現在提供一種方法解決這種問題，那就是在ORACLE中殺不掉的，在OS一級再殺。 &lt;br /&gt;&lt;br /&gt;1.下面的語句用來查詢哪些對像被鎖： &lt;br /&gt;&lt;br /&gt;select object_name,machine,s.sid,s.serial# &lt;br /&gt;from v$locked_object l,dba_objects o ,v$session s &lt;br /&gt;where l.object_id　=　o.object_id and l.session_id=s.sid; &lt;br /&gt;2.下面的語句用來殺死一個進程： &lt;br /&gt;alter system kill session &#39;24,111&#39;; (其中24,111分別是上面查詢出的sid,serial#) &lt;br /&gt;【注】以上兩步，可以通過Oracle的管理控制台來執行。 &lt;br /&gt;3.如果利用上面的命令殺死一個進程後，進程狀態被置為&quot;killed&quot;，但是鎖定的資源很長時間沒有被釋放，那麼可以在os一級再殺死相應的進程（線程），首先執行下面的語句獲得進程（線程）號： &lt;br /&gt;select p.spid, osuser, s.program &lt;br /&gt;from v$session s,v$process p &lt;br /&gt;where s.paddr=p.addr and s.sid=24 （24是上面的sid） &lt;br /&gt;4.在OS上殺死這個進程（線程）： &lt;br /&gt;1)在unix上，用root身份執行命令: &lt;br /&gt;#kill -9 12345（即第3步查詢出的spid） &lt;br /&gt;2)在windows（unix也適用）用orakill殺死線程，orakill是oracle提供的一個可執行命令，語法為： &lt;br /&gt;orakill sid thread &lt;br /&gt;其中： &lt;br /&gt;sid：表示要殺死的進程屬於的實例名 &lt;br /&gt;thread：是要殺掉的線程號，即第3步查詢出的spid。 &lt;br /&gt;例：c:&gt;orakill orcl 12345 &lt;br /&gt;&lt;br /&gt;ORA-00031: session marked for kill &lt;br /&gt;&lt;br /&gt;Cause: The session specified in an ALTER SYSTEM KILL SESSION command cannot be killed immediately (because it is rolling back or blocked on a network operation), but it has been marked for kill. This means it will be killed as soon as possible after its current uninterruptible operation is done. &lt;br /&gt;Action: No action is required for the session to be killed, but further executions of the ALTER SYSTEM KILL SESSION command on this session may cause the session to be killed sooner. &lt;br /&gt;  &lt;br /&gt;kill -9 12345&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;source: http://unixboy.javaeye.com/blog/168346&lt;br /&gt;http://www.oracle-base.com/articles/misc/KillingOracleSessions.php</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/6834962383505993516/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/6834962383505993516' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/6834962383505993516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/6834962383505993516'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/01/ora-00031-session-marked-for-kill.html' title='ORA-00031: session marked for kill 處理Oracle中殺不掉的鎖'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-8597696743139406248</id><published>2011-01-05T00:06:00.000-08:00</published><updated>2011-01-05T00:09:12.787-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><category scheme="http://www.blogger.com/atom/ns#" term="MSSQL"/><title type='text'>T-SQL While Loop</title><content type='html'>declare @Part_Id int&lt;br /&gt; declare @Category_Id int&lt;br /&gt; declare @Desc varchar(50)&lt;br /&gt; create table PART (Part_Id int, Category_Id int, Description varchar(50))&lt;br /&gt; set @Part_Id = 0&lt;br /&gt; set @Category_Id = 0 &lt;br /&gt; while @Part_Id &lt; 2&lt;br /&gt; begin&lt;br /&gt;   set @Part_Id = @Part_Id + 1&lt;br /&gt;   while @Category_Id &lt; 3&lt;br /&gt;   begin &lt;br /&gt;     set @Category_Id = @Category_Id + 1&lt;br /&gt;     set @Desc = &#39;Part_Id is &#39; + cast(@Part_Id as char(1)) +&lt;br /&gt;                 &#39; Category_Id &#39; + cast(@Category_Id as char(1))&lt;br /&gt;     insert into PART values(@Part_Id, &lt;br /&gt;                             @Category_Id,&lt;br /&gt;                             @Desc )&lt;br /&gt;   end  &lt;br /&gt;   set @Category_Id = 0 &lt;br /&gt; end&lt;br /&gt; select * from PART&lt;br /&gt; drop table PART&lt;br /&gt;Here is the output from the SELECT statement at the bottom of this nested WHILE loop example.&lt;br /&gt;&lt;br /&gt; Part_Id     Category_Id Description                                        &lt;br /&gt; ----------- ----------- ----------------------------------------- &lt;br /&gt; 1           1           Part_Id is 1 Category_Id 1&lt;br /&gt; 1           2           Part_Id is 1 Category_Id 2&lt;br /&gt; 1           3           Part_Id is 1 Category_Id 3&lt;br /&gt; 2           1           Part_Id is 2 Category_Id 1&lt;br /&gt; 2           2           Part_Id is 2 Category_Id 2&lt;br /&gt; 2           3           Part_Id is 2 Category_Id 3</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/8597696743139406248/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/8597696743139406248' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/8597696743139406248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/8597696743139406248'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/01/t-sql-while-loop.html' title='T-SQL While Loop'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-272429821527780388.post-3897596775885532542</id><published>2011-01-04T23:59:00.000-08:00</published><updated>2011-01-05T00:04:43.781-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Database"/><title type='text'>SQL Server日期函數CONVERT範例</title><content type='html'>MS SQL Server中文版的預設日期datetime格式是yyyy-mm-dd hh:mm:ss.mmm&lt;br /&gt;&lt;br /&gt;例如:&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#000099;&quot;&gt;select getdate()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2011-01-05 11:06:08.177&lt;br /&gt;&lt;br /&gt;SQL Server常用到日期格式轉換方式如下：&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;select CONVERT(varchar, getdate(), 120 )&lt;/span&gt;&lt;br /&gt;2004-09-12 11:06:08&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),’-&#39;,”),’ ‘,”),’:&#39;,”)&lt;/span&gt;&lt;br /&gt;20040912110608&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;select CONVERT(varchar(12) , getdate(), 111 )&lt;/span&gt;&lt;br /&gt;2004/09/12&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Text Convert to Datetime&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;color:#3333FF;&quot;&gt;SELECT  convert(datetime, &#39;09/02/2010&#39;, 103)&lt;/span&gt;&lt;br /&gt;here 103-&gt;英國/法國標準&lt;br /&gt;&lt;br /&gt;source: &lt;a href=&quot;http://technet.microsoft.com/zh-tw/library/ms187928.aspx&quot;&gt;http://technet.microsoft.com/zh-tw/library/ms187928.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://codestandup.blogspot.com/feeds/3897596775885532542/comments/default' title='張貼留言'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/272429821527780388/3897596775885532542' title='0 個意見'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/3897596775885532542'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/272429821527780388/posts/default/3897596775885532542'/><link rel='alternate' type='text/html' href='http://codestandup.blogspot.com/2011/01/sql-serverconvert.html' title='SQL Server日期函數CONVERT範例'/><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>