update introduction
This commit is contained in:
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="1.1" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="1.1" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_51">
|
||||
<section class="normal" id="section-gitbook_595">
|
||||
|
||||
<h1 id="-swift">关于 Swift</h1>
|
||||
<p>Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用程序。Swift 结合了 C 和 Objective-C 的优点并且不受C的兼容性的限制。Swift 使用安全的编程模式并添加了很多新特性,这将使编程更简单,扩展性更强,也更有趣。除此之外,Swift 还支持人见人爱的 Cocoa 和 Cocoa Touch 框架。拥有了这些特性,Swift将重新定义软件开发。</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="1.2" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="1.2" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_53">
|
||||
<section class="normal" id="section-gitbook_596">
|
||||
|
||||
<h1 id="swift-">Swift 初见</h1>
|
||||
<p>本页内容包括:</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="1" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="1" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_52">
|
||||
<section class="normal" id="section-gitbook_597">
|
||||
|
||||
<h1 id="-swift">欢迎使用 Swift</h1>
|
||||
<p>在本章中您将了解 Swift 的特性和开发历史,并对 Swift 有一个初步的了解。</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.1" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.1" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_55">
|
||||
<section class="normal" id="section-gitbook_599">
|
||||
|
||||
<h1 id="-">基础部分</h1>
|
||||
<p>Swift 是 iOS 和 OS X 应用开发的一门新语言。然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的。</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.2" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.2" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_66">
|
||||
<section class="normal" id="section-gitbook_609">
|
||||
|
||||
<h1 id="-">基础运算符</h1>
|
||||
<p>运算符是检查, 改变, 合并值的特殊符号或短语. 例如, 加号 <code>+</code> 把计算两个数的和(如 <code>let i = 1 + 2</code>). 复杂些的运行算包括逻辑与<code>&&</code>(如 <code>if enteredDoorCode && passedRetinaScan</code>), 还有自增运算符 <code>++i</code> 这样让自身加一的便捷运算.</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.3" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.3" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_56">
|
||||
<section class="normal" id="section-gitbook_600">
|
||||
|
||||
<h1 id="-strings-and-characters-">字符串和字符 (Strings and Characters)</h1>
|
||||
<p>本页包含内容:</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.4" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.4" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.5" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.5" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.6" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.6" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_59">
|
||||
<section class="normal" id="section-gitbook_603">
|
||||
|
||||
<h1 id="-functions-">函数(Functions)</h1>
|
||||
<p>本页包含内容:</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.7" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.7" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_60">
|
||||
<section class="normal" id="section-gitbook_604">
|
||||
|
||||
<h1 id="-">闭包</h1>
|
||||
<p>本页内容包含:</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.8" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.8" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.9" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.9" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_62">
|
||||
<section class="normal" id="section-gitbook_606">
|
||||
|
||||
<h3 id="-">类和结构体</h3>
|
||||
<p>本页包含内容:</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.10" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.10" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.11" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.11" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.12" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.12" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.13" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.13" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.14" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.14" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.15" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.15" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.16" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.16" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_69">
|
||||
<section class="normal" id="section-gitbook_614">
|
||||
|
||||
<h1 id="-">自动引用计数</h1>
|
||||
<p>本页包含内容:</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.17" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.17" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.18" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.18" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_71">
|
||||
<section class="normal" id="section-gitbook_615">
|
||||
|
||||
<h1 id="-type-casting-">类型检查(Type Casting)</h1>
|
||||
<p>(ps:为了方便各位检验所以保留了英文,可删。)
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.19" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.19" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_72">
|
||||
<section class="normal" id="section-gitbook_616">
|
||||
|
||||
<h1 id="-">类型嵌套</h1>
|
||||
<p>本页包含内容:</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.20" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.20" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -584,7 +584,7 @@
|
||||
<a href="../chapter2/19_Nested_Types.html" class="navigation navigation-prev " aria-label="Previous page: 嵌套类型"><i class="fa fa-angle-left"></i></a>
|
||||
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" class="navigation navigation-next " aria-label="Next page: 接口"><i class="fa fa-angle-right"></i></a>
|
||||
<a href="../chapter2/21_Protocols.html" class="navigation navigation-next " aria-label="Next page: 协议"><i class="fa fa-angle-right"></i></a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<title>接口 | Swift 编程语言</title>
|
||||
<title>协议 | Swift 编程语言</title>
|
||||
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<meta name="robots" content="index, follow">
|
||||
@ -21,7 +21,7 @@
|
||||
<link rel="prev" href="../chapter2/20_Extensions.html" />
|
||||
|
||||
|
||||
<meta property="og:title" content="接口 | Swift 编程语言">
|
||||
<meta property="og:title" content="协议 | Swift 编程语言">
|
||||
<meta property="og:site_name" content="Swift 编程语言">
|
||||
<meta property="og:type" content="book">
|
||||
<meta property="og:locale" content="en_US">
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.21" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.21" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.22" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.22" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_75">
|
||||
<section class="normal" id="section-gitbook_619">
|
||||
|
||||
<h1 id="-">泛型</h1>
|
||||
<hr>
|
||||
@ -943,7 +943,7 @@ var arrayOfStrings = [<span class="hljs-string">"uno"</span>, <span class="hljs-
|
||||
</div>
|
||||
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" class="navigation navigation-prev " aria-label="Previous page: 接口"><i class="fa fa-angle-left"></i></a>
|
||||
<a href="../chapter2/21_Protocols.html" class="navigation navigation-prev " aria-label="Previous page: 协议"><i class="fa fa-angle-left"></i></a>
|
||||
|
||||
|
||||
<a href="../chapter2/23_Advanced_Operators.html" class="navigation navigation-next " aria-label="Next page: 高级操作符"><i class="fa fa-angle-right"></i></a>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.23" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2.23" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="2" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_79">
|
||||
<section class="normal" id="section-gitbook_623">
|
||||
|
||||
<h1 id="swift-">Swift 教程</h1>
|
||||
<p>本章介绍了 Swift 的各种特性及其使用方法,是全书的核心部分。</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3.1" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3.1" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -576,7 +576,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_80">
|
||||
<section class="normal" id="section-gitbook_624">
|
||||
|
||||
<h1 id="-">关于语言附注</h1>
|
||||
<p>本书的这一节描述了Swift编程语言的形式语法。这里描述的语法是为了帮助您更详细的了解该语言,而不是让您直接实现一个解析器或编译器。</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3.2" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3.2" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3.3" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3.3" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3.4" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3.4" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3.5" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3.5" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter done " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -584,7 +584,7 @@
|
||||
<a href="../chapter3/04_Expressions.html" class="navigation navigation-prev " aria-label="Previous page: 表达式"><i class="fa fa-angle-left"></i></a>
|
||||
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" class="navigation navigation-next " aria-label="Next page: 属性"><i class="fa fa-angle-right"></i></a>
|
||||
<a href="../chapter3/06_Attributes.html" class="navigation navigation-next " aria-label="Next page: 特性"><i class="fa fa-angle-right"></i></a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<title>属性 | Swift 编程语言</title>
|
||||
<title>特性 | Swift 编程语言</title>
|
||||
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<meta name="robots" content="index, follow">
|
||||
@ -21,7 +21,7 @@
|
||||
<link rel="prev" href="../chapter3/05_Declarations.html" />
|
||||
|
||||
|
||||
<meta property="og:title" content="属性 | Swift 编程语言">
|
||||
<meta property="og:title" content="特性 | Swift 编程语言">
|
||||
<meta property="og:site_name" content="Swift 编程语言">
|
||||
<meta property="og:type" content="book">
|
||||
<meta property="og:locale" content="en_US">
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3.6" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3.6" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter done " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter done " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter done " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3.7" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3.7" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter done " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter done " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter done " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter done " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -581,7 +581,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" class="navigation navigation-prev " aria-label="Previous page: 属性"><i class="fa fa-angle-left"></i></a>
|
||||
<a href="../chapter3/06_Attributes.html" class="navigation navigation-prev " aria-label="Previous page: 特性"><i class="fa fa-angle-left"></i></a>
|
||||
|
||||
|
||||
<a href="../chapter3/08_Generic_Parameters_and_Arguments.html" class="navigation navigation-next " aria-label="Next page: 泛型参数"><i class="fa fa-angle-right"></i></a>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3.8" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3.8" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter done " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter done " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter done " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter done " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3.9" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3.9" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -347,7 +347,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -434,7 +434,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -529,7 +529,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -561,7 +561,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter done " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter done " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter done " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter done " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="3" data-basepath=".." data-revision="1402183488921">
|
||||
<div class="book" data-level="3" data-basepath=".." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -349,7 +349,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="../chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="../chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -531,7 +531,7 @@
|
||||
|
||||
<a href="../chapter2/20_Extensions.html" title="扩展" class="chapter done " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="../chapter2/21_Protocols.html" title="接口" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="../chapter2/21_Protocols.html" title="协议" class="chapter done " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="../chapter2/22_Generics.html" title="泛型" class="chapter done " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -563,7 +563,7 @@
|
||||
|
||||
<a href="../chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="../chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="../chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="../chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
|
||||
17
index.html
17
index.html
@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="0" data-basepath="." data-revision="1402183488921">
|
||||
<div class="book" data-level="0" data-basepath="." data-revision="1402189909808">
|
||||
<div class="book-header">
|
||||
<!-- Actions Left -->
|
||||
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
|
||||
@ -347,7 +347,7 @@
|
||||
<li class="chapter " data-level="2.21" data-path="chapter2/21_Protocols.html">
|
||||
|
||||
<a href="./chapter2/21_Protocols.html">
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 接口
|
||||
<i class="fa fa-check"></i> <b>2.21.</b> 协议
|
||||
</a>
|
||||
|
||||
|
||||
@ -434,7 +434,7 @@
|
||||
<li class="chapter " data-level="3.6" data-path="chapter3/06_Attributes.html">
|
||||
|
||||
<a href="./chapter3/06_Attributes.html">
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 属性
|
||||
<i class="fa fa-check"></i> <b>3.6.</b> 特性
|
||||
</a>
|
||||
|
||||
|
||||
@ -529,7 +529,7 @@
|
||||
|
||||
<a href="./chapter2/20_Extensions.html" title="扩展" class="chapter " data-progress="2.20" style="left: 45.945945945945944%;"></a>
|
||||
|
||||
<a href="./chapter2/21_Protocols.html" title="接口" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
<a href="./chapter2/21_Protocols.html" title="协议" class="chapter " data-progress="2.21" style="left: 48.648648648648646%;"></a>
|
||||
|
||||
<a href="./chapter2/22_Generics.html" title="泛型" class="chapter " data-progress="2.22" style="left: 51.351351351351354%;"></a>
|
||||
|
||||
@ -561,7 +561,7 @@
|
||||
|
||||
<a href="./chapter3/05_Declarations.html" title="声明" class="chapter " data-progress="3.5" style="left: 89.1891891891892%;"></a>
|
||||
|
||||
<a href="./chapter3/06_Attributes.html" title="属性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
<a href="./chapter3/06_Attributes.html" title="特性" class="chapter " data-progress="3.6" style="left: 91.89189189189189%;"></a>
|
||||
|
||||
<a href="./chapter3/07_Patterns.html" title="模式" class="chapter " data-progress="3.7" style="left: 94.5945945945946%;"></a>
|
||||
|
||||
@ -574,11 +574,14 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_50">
|
||||
<section class="normal" id="section-gitbook_594">
|
||||
|
||||
<h1 id="swift-">Swift 编程语言</h1>
|
||||
<p>Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。</p>
|
||||
<p>感谢您的阅读。</p>
|
||||
<p>翻译正在进行中,翻译完成的部分会实时同步到这里。您可以到<a href="https://github.com/numbbbbb/the-swift-programming-language-in-chinese" target="_blank">项目首页</a>查看当前进度。</p>
|
||||
<p>由于是多人协同翻译,可能会有些术语或者句子翻译不太恰当,如果您在阅读过程中发现此类问题,请直接给我们提 issue 或者 pull request。翻译完成后我们会进行认真的校对,给大家提供一本高质量的 Swift 教程。</p>
|
||||
<p>如果您愿意加入进来,帮助我们进行翻译和校对,请阅读<a href="https://github.com/numbbbbb/the-swift-programming-language-in-chinese" target="_blank">项目首页</a>中的说明并加入QQ群:364279588,我们期待您的加入,在 Swift 的历史上留下您的足迹!</p>
|
||||
<p>最后,非常感谢您的阅读,如果您觉得本文不错的话请分享给其他人,您的支持就是我们最大的动力!</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
CACHE MANIFEST
|
||||
# Revision 1402183488922
|
||||
# Revision 1402189909809
|
||||
|
||||
CACHE:
|
||||
index.html
|
||||
chapter1/01_swift.html
|
||||
chapter1/chapter1.html
|
||||
chapter1/02_a_swift_tour.html
|
||||
chapter1/chapter1.html
|
||||
chapter2/13_Inheritance.html
|
||||
chapter2/01_The_Basics.html
|
||||
chapter2/03_Strings_and_Characters.html
|
||||
@ -15,14 +15,14 @@ chapter2/06_Functions.html
|
||||
chapter2/07_Closures.html
|
||||
chapter2/08_Enumerations.html
|
||||
chapter2/09_Classes_and_Structures.html
|
||||
chapter2/10_Properties.html
|
||||
chapter2/11_Methods.html
|
||||
chapter2/12_Subscripts.html
|
||||
chapter2/02_Basic_Operators.html
|
||||
chapter2/10_Properties.html
|
||||
chapter2/14_Initialization.html
|
||||
chapter2/15_Deinitialization.html
|
||||
chapter2/16_Automatic_Reference_Counting.html
|
||||
chapter2/17_Optional_Chaining.html
|
||||
chapter2/16_Automatic_Reference_Counting.html
|
||||
chapter2/18_Type_Casting.html
|
||||
chapter2/19_Nested_Types.html
|
||||
chapter2/20_Extensions.html
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -2,5 +2,11 @@
|
||||
|
||||
Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。
|
||||
|
||||
感谢您的阅读。
|
||||
翻译正在进行中,翻译完成的部分会实时同步到这里。您可以到[项目首页](https://github.com/numbbbbb/the-swift-programming-language-in-chinese)查看当前进度。
|
||||
|
||||
由于是多人协同翻译,可能会有些术语或者句子翻译不太恰当,如果您在阅读过程中发现此类问题,请直接给我们提 issue 或者 pull request。翻译完成后我们会进行认真的校对,给大家提供一本高质量的 Swift 教程。
|
||||
|
||||
如果您愿意加入进来,帮助我们进行翻译和校对,请阅读[项目首页](https://github.com/numbbbbb/the-swift-programming-language-in-chinese)中的说明并加入QQ群:364279588,我们期待您的加入,在 Swift 的历史上留下您的足迹!
|
||||
|
||||
最后,非常感谢您的阅读,如果您觉得本文不错的话请分享给其他人,您的支持就是我们最大的动力!
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
* [类型检查](chapter2/18_Type_Casting.md)
|
||||
* [嵌套类型](chapter2/19_Nested_Types.md)
|
||||
* [扩展](chapter2/20_Extensions.md)
|
||||
* [接口](chapter2/21_Protocols.md)
|
||||
* [协议](chapter2/21_Protocols.md)
|
||||
* [泛型](chapter2/22_Generics.md)
|
||||
* [高级操作符](chapter2/23_Advanced_Operators.md)
|
||||
* [语言参考](chapter3/chapter3.md)
|
||||
@ -33,7 +33,7 @@
|
||||
* [类型](chapter3/03_Types.md)
|
||||
* [表达式](chapter3/04_Expressions.md)
|
||||
* [声明](chapter3/05_Declarations.md)
|
||||
* [属性](chapter3/06_Attributes.md)
|
||||
* [特性](chapter3/06_Attributes.md)
|
||||
* [模式](chapter3/07_Patterns.md)
|
||||
* [泛型参数](chapter3/08_Generic_Parameters_and_Arguments.md)
|
||||
* [语法总结](chapter3/09_Summary_of_the_Grammar.md)
|
||||
|
||||
@ -1,21 +1,5 @@
|
||||
# 基础部分
|
||||
|
||||
本页包含内容:
|
||||
|
||||
- 常量与变量
|
||||
- 注释
|
||||
- 分号
|
||||
- 整数
|
||||
- 浮点数
|
||||
- 类型安全和类型推导
|
||||
- 数值类原始值
|
||||
- 数值类型转换
|
||||
- 类型别名
|
||||
- 布尔值
|
||||
- 元组
|
||||
- 可选
|
||||
- 断言
|
||||
|
||||
Swift 是 iOS 和 OS X 应用开发的一门新语言。然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的。
|
||||
|
||||
Swift 的类型是在 C 和 Objective-C 的基础上提出的,`Int`是整型;`Double`和`Float`是浮点型;`Bool`是布尔型;`String`是字符串。Swift 还有两个有用的集合类型,`Array`和`Dictionary`,详情参见`集合类型(待添加链接)`。
|
||||
@ -176,7 +160,7 @@ Swift 也提供了一个特殊的无符号类型`UInt`,长度与当前平台
|
||||
* 在32位平台上,`UInt`和`UInt32`长度相同。
|
||||
* 在64位平台上,`UInt`和`UInt64`长度相同。
|
||||
|
||||
> 注意:尽量不要使用`UInt`,除非你真的需要存储一个和当前平台原生字长相同的无符号整数。除了这种情况,最好使用`Int`,即使你要存储的值已知是非负的。统一使用`Int`可以提高代码的可复用性,避免不同类型数字之间的转换,并且匹配数字的类型推导,详情参见[类型安全和类型推导](## 类型安全和类型推导)。
|
||||
> 注意:尽量不要使用`UInt`,除非你真的需要存储一个和当前平台原生字长相同的无符号整数。除了这种情况,最好使用`Int`,即使你要存储的值已知是非负的。统一使用`Int`可以提高代码的可复用性,避免不同类型数字之间的转换,并且匹配数字的类型推测,详情参见[类型安全和类型推测](## 类型安全和类型推测)。
|
||||
|
||||
## 浮点数
|
||||
|
||||
@ -189,36 +173,36 @@ Swift 也提供了一个特殊的无符号类型`UInt`,长度与当前平台
|
||||
|
||||
> 注意:`Double`精确度很高,至少有15位数字,而`Float`最少只有6位数字。选择哪个类型取决于你的代码需要处理的数字大小。
|
||||
|
||||
## 类型安全和类型推导
|
||||
## 类型安全和类型推测
|
||||
|
||||
Swift 是一个类型安全的语言。类型安全的语言可以让你清楚地知道代码要处理的值的类型。如果你的代码需要一个`String`,你绝对不可能不小心传进去一个`Int`。
|
||||
|
||||
Swift 是类型安全的,会在编译你的代码时进行类型检查,如果遇到不匹配的类型会报错。这可以让你在开发的时候尽早发现并修复错误。
|
||||
|
||||
当你要处理不同类型的值时,类型检查可以帮你避免错误。然而,这并不是说你每次声明常量和变量的时候都需要显式指定类型。如果你没有显式指定类型,Swift 会使用类型推导来选择合适的类型。有了类型推导,编译器可以在编译代码的时候自动推导出表达式的类型。原理很简单,判断你赋的值即可。
|
||||
当你要处理不同类型的值时,类型检查可以帮你避免错误。然而,这并不是说你每次声明常量和变量的时候都需要显式指定类型。如果你没有显式指定类型,Swift 会使用类型推测来选择合适的类型。有了类型推测,编译器可以在编译代码的时候自动推测出表达式的类型。原理很简单,判断你赋的值即可。
|
||||
|
||||
因为有类型推导,和 C 或者 Objc 比起来 Swift 很少需要声明类型。常量和变量虽然需要明确类型,但是大部分工作并不需要你自己来完成。
|
||||
因为有类型推测,和 C 或者 Objc 比起来 Swift 很少需要声明类型。常量和变量虽然需要明确类型,但是大部分工作并不需要你自己来完成。
|
||||
|
||||
当你声明常量或者变量并赋初值的时候类型推导非常有用。当你在声明常量或者变量的时候赋给它们一个原始值即可触发类型推导。(原始值就是会直接出现在你代码中的值,比如`42`和`3.14159`。)
|
||||
当你声明常量或者变量并赋初值的时候类型推测非常有用。当你在声明常量或者变量的时候赋给它们一个原始值即可触发类型推测。(原始值就是会直接出现在你代码中的值,比如`42`和`3.14159`。)
|
||||
|
||||
举个例子,如果你给一个新常量赋值`42`并且没有标明类型,Swift 可以推导出常量类型是`Int`,因为你给它赋的初值看起来很像一个整数:
|
||||
举个例子,如果你给一个新常量赋值`42`并且没有标明类型,Swift 可以推测出常量类型是`Int`,因为你给它赋的初值看起来很像一个整数:
|
||||
|
||||
let meaningOfLife = 42
|
||||
// meaningOfLife 会被推导为 Int 类型
|
||||
// meaningOfLife 会被推测为 Int 类型
|
||||
|
||||
同理,如果你没有给浮点原始值标明类型,Swift 会推导你想要的是`Double`:
|
||||
同理,如果你没有给浮点原始值标明类型,Swift 会推测你想要的是`Double`:
|
||||
|
||||
let pi = 3.14159
|
||||
// pi 会被推导为 Double 类型
|
||||
// pi 会被推测为 Double 类型
|
||||
|
||||
当推导浮点数的类型时,Swift 总是会选择`Double`而不是`Float`。
|
||||
当推测浮点数的类型时,Swift 总是会选择`Double`而不是`Float`。
|
||||
|
||||
如果表达式中同时出现了整数和浮点数,会被推导为`Double`类型:
|
||||
如果表达式中同时出现了整数和浮点数,会被推测为`Double`类型:
|
||||
|
||||
let anotherPi = 3 + 0.14159
|
||||
// anotherPi 会被推导为 Double 类型
|
||||
// anotherPi 会被推测为 Double 类型
|
||||
|
||||
原始值`3`没有显式声明类型,而表达式中出现了一个浮点原始值,所以表达式会被推导为`Double`类型。
|
||||
原始值`3`没有显式声明类型,而表达式中出现了一个浮点原始值,所以表达式会被推测为`Double`类型。
|
||||
|
||||
## 数值类原始值
|
||||
|
||||
@ -260,8 +244,7 @@ Swift 是类型安全的,会在编译你的代码时进行类型检查,如
|
||||
|
||||
## 数值类型转换
|
||||
|
||||
通常来讲,即使代码中的整数常量和变量已知非负,也请使用`Int`类型。总是使用默认的整数类型可以保证你的整数常量和变量可以直接被复用并且可以匹配整数类原始值的类型推导。
|
||||
|
||||
通常来讲,即使代码中的整数常量和变量已知非负,也请使用`Int`类型。总是使用默认的整数类型可以保证你的整数常量和变量可以直接被复用并且可以匹配整数类原始值的类型推测。
|
||||
只有在必要的时候才使用其他整数类型,比如要处理外部的长度明确的数据或者为了优化性能、内存占用等等。使用显式指定长度的类型可以及时发现值溢出并且可以暗示正在处理特殊数据。
|
||||
|
||||
### 整数转换
|
||||
@ -281,7 +264,7 @@ Swift 是类型安全的,会在编译你的代码时进行类型检查,如
|
||||
let one: UInt8 = 1
|
||||
let twoThousandAndOne = twoThousand + UInt16(one)
|
||||
|
||||
现在两个数字的类型都是`UInt16`,可以进行相加。目标常量`twoThousandAndOne`的类型被推导为`UInt16`,因为它是两个`UInt16`值的合。
|
||||
现在两个数字的类型都是`UInt16`,可以进行相加。目标常量`twoThousandAndOne`的类型被推测为`UInt16`,因为它是两个`UInt16`值的合。
|
||||
|
||||
`SomeType(ofInitialValue)`是调用 Swift 构造器并传入一个初始值的默认方法。在语言内部,`UInt16`有一个构造器,可以接受一个`UInt8`类型的值,所以这个构造器可以用现有的`UInt8`来创建一个新的`UInt16`。注意,你并不能传入任意类型的值,只能传入`UInt16`内部有对应构造器的值。不过你可以扩展现有的类型来让它可以接收其他类型的值(包括自定义类型),详情参见`扩展(链接待添加)`.
|
||||
|
||||
@ -292,18 +275,18 @@ Swift 是类型安全的,会在编译你的代码时进行类型检查,如
|
||||
let three = 3
|
||||
let pointOneFourOneFiveNine = 0.14159
|
||||
let pi = Double(three) + pointOneFourOneFiveNine
|
||||
// pi 等于 3.14159,所以被推导为 Double 类型
|
||||
// pi 等于 3.14159,所以被推测为 Double 类型
|
||||
|
||||
这个例子中,常量`three`的值被用来创建一个`Double`类型的值,所以加号两边的数类型相同。如果不进行转换,两者无法相加。
|
||||
|
||||
浮点数转换为整数也一样,整数类型可以用`Double`或者`Float`类型来初始化:
|
||||
|
||||
let integerPi = Int(pi)
|
||||
// integerPi 等于 3,所以被推导为 Int 类型
|
||||
// integerPi 等于 3,所以被推测为 Int 类型
|
||||
|
||||
当用这种方式来初始化一个新的整数值时,浮点值会被截断。也就是说`4.75`会变成`4`,`-3.9`会变成`3`。
|
||||
|
||||
> 注意:结合数字类常量和变量不同于结合数字类原始值。原始值`3`可以直接和原始值`0.14159`相加,因为数字原始值本身没有明确的类型。它们的类型只在编译器需要求值的时候被推导。
|
||||
> 注意:结合数字类常量和变量不同于结合数字类原始值。原始值`3`可以直接和原始值`0.14159`相加,因为数字原始值本身没有明确的类型。它们的类型只在编译器需要求值的时候被推测。
|
||||
|
||||
## 类型别名
|
||||
|
||||
@ -327,7 +310,7 @@ Swift 有一个基本的布尔类型,叫做`Bool`。布尔值是指逻辑,
|
||||
let orangesAreOrange = true
|
||||
let turnipsAreDelicious = false
|
||||
|
||||
`orangesAreOrange`和`turnipsAreDelicious`的类型会被推导为`Bool`,因为它们的初值是布尔原始值。就像之前提到的`Int`和`Double`一样,如果你创建变量的时候给它们赋值`true`或者`false`,那你不需要给常量或者变量标明`Bool`类型。初始化常量或者变量的时候如果所赋的值类型已知,就可以触发类型推导,这让 Swift 代码更加简洁并且可读性更高。
|
||||
`orangesAreOrange`和`turnipsAreDelicious`的类型会被推测为`Bool`,因为它们的初值是布尔原始值。就像之前提到的`Int`和`Double`一样,如果你创建变量的时候给它们赋值`true`或者`false`,那你不需要给常量或者变量标明`Bool`类型。初始化常量或者变量的时候如果所赋的值类型已知,就可以触发类型推测,这让 Swift 代码更加简洁并且可读性更高。
|
||||
|
||||
当你编写条件语句比如`if`语句的时候,布尔值非常有用:
|
||||
|
||||
@ -417,7 +400,7 @@ Swift 有一个基本的布尔类型,叫做`Bool`。布尔值是指逻辑,
|
||||
|
||||
* 没有值
|
||||
|
||||
> 注意:C 和 Objective-C 中并没有可选这个概念。最接近的是 Objective-C 中的一个特性,一个方法要不返回一个对象要不返回`nil`,`nil`表示“缺少一个合法的对象”。然而,这只对对象起作用——对于结构体,基本的 C 类型或者美剧类型不起作用。对于这些类型,Objective-C 方法一般会返回一个特殊值(比如`NSNotFound`)来暗示值缺失。这种方法假设方法的调用者知道并记得对特殊值进行判断。然而,Swift 的可选可以让你暗示任意类型的值缺失,并不需要一个特殊值。
|
||||
> 注意:C 和 Objective-C 中并没有可选这个概念。最接近的是 Objective-C 中的一个特性,一个方法要不返回一个对象要不返回`nil`,`nil`表示“缺少一个合法的对象”。然而,这只对对象起作用——对于结构体,基本的 C 类型或者枚举类型不起作用。对于这些类型,Objective-C 方法一般会返回一个特殊值(比如`NSNotFound`)来暗示值缺失。这种方法假设方法的调用者知道并记得对特殊值进行判断。然而,Swift 的可选可以让你暗示任意类型的值缺失,并不需要一个特殊值。
|
||||
|
||||
来看一个例子。Swift 的`String`类型有一个叫做`toInt`的方法,作用是将一个`String`值转换成一个`Int`值。然而,并不是所有的字符串都可以转换成一个整数。字符串`"123"`可以被转换成数字`123`,但是字符串`"hello, world"`不行。
|
||||
|
||||
@ -425,7 +408,7 @@ Swift 有一个基本的布尔类型,叫做`Bool`。布尔值是指逻辑,
|
||||
|
||||
let possibleNumber = "123"
|
||||
let convertedNumber = possibleNumber.toInt()
|
||||
// convertedNumber 被推导为类型 "Int?", 或者类型 "optional Int"
|
||||
// convertedNumber 被推测为类型 "Int?", 或者类型 "optional Int"
|
||||
|
||||
因为`toInt`方法可能会失败,所以它返回一个可选的`Int`,而不是一个`Int`。一个可选的`Int`被写作`Int?`而不是`Int`。问号暗示包含的值是可选,也就是说可能包含`Int`值也可能不包含值。(不能包含其他任何值比如`Bool`值或者`String`值。只能是`Int`或者什么都没有。)
|
||||
|
||||
|
||||
@ -0,0 +1,293 @@
|
||||
#类型检查(Type Casting)
|
||||
|
||||
(ps:为了方便各位检验所以保留了英文,可删。)
|
||||
_类型检查_是一种检查类实例的方式,并且哦或者也是让实例作为它的父类或者子类的一种方式。
|
||||
|
||||
_Type casting_ is a way to check the type of an instance, and/or to treat that instance as if it is a different superclass or subclass from somewhere else in its own class hierarchy.
|
||||
|
||||
类型检查在Swift中使用`is` 和 `as`操作符实现。这两个操作符提供了一种简单达意的方式去检查值的类型或者转换它的类型。
|
||||
|
||||
Type casting in Swift is implemented with the `is` and `as` operators. These two operators provide a simple and expressive way to check the type of a value or cast a value to a different type.
|
||||
|
||||
你也可以用来检查一个类是否实现了某个协议,就像在 [Protocols》Checking for Protocol Conformance](Protocols.html#//apple_ref/doc/uid/TP40014097-CH25-XID_363)部分讲述的一样。
|
||||
|
||||
You can also use type casting to check whether a type conforms to a protocol, as described in <span class="x-name">[Checking for Protocol Conformance](Protocols.html#//apple_ref/doc/uid/TP40014097-CH25-XID_363)</span>.
|
||||
### 定义一个类层次作为例子Defining a Class Hierarchy for Type Casting
|
||||
|
||||
你可以将它用在类和子类的层次结构上,检查特定类实例的类型并且转换这个类实例的类型成为这个层次结构中的其他类型。这下面的三个代码段定义了一个类层次和一个array包含了几个这些类的实例,作为类型检查的例子。
|
||||
|
||||
You can use type casting with a hierarchy of classes and subclasses to check the type of a particular class instance and to cast that instance to another class within the same hierarchy. The three code snippets below define a hierarchy of classes and an array containing instances of those classes, for use in an example of type casting.
|
||||
|
||||
第一个代码片段定义了一个新的基础类`MediaItem`。这个类为任何出现在数字媒体库的项提供基础功能。特别的,它声明了一个 `String` 类型的 `name` 属性,和一个`init name`初始化器。(它假定所有的媒体项都有个名称。)
|
||||
|
||||
The first snippet defines a new base class called `MediaItem`. This class provides basic functionality for any kind of item that appears in a digital media library. Specifically, it declares a `name` property of type `String`, and an `init name` initializer. (It is assumed that all media items, including all movies and songs, will have a name.)
|
||||
|
||||
class MediaItem {
|
||||
var name: String
|
||||
init(name: String) {
|
||||
self.name = name
|
||||
}
|
||||
}
|
||||
|
||||
下一个代码段定义了 `MediaItem` 的两个子类。第一个子类`Movie`,在父类(或者说基类)的基础上增加了一个 `director`(导演) 属性,和相应的初始化器。第二个类在父类的基础上增加了一个 `artist`(艺术家) 属性,和相应的初始化器:
|
||||
|
||||
The next snippet defines two subclasses of `MediaItem`. The first subclass, `Movie`, encapsulates additional information about a movie or film. It adds a `director` property on top of the base `MediaItem` class, with a corresponding initializer. The second subclass, `Song`, adds an `artist` property and initializer on top of the base class:
|
||||
|
||||
class Movie: MediaItem {
|
||||
var director: String
|
||||
init(name: String, director: String) {
|
||||
self.director = director
|
||||
super.init(name: name)
|
||||
}
|
||||
}
|
||||
|
||||
class Song: MediaItem {
|
||||
var artist: String
|
||||
init(name: String, artist: String) {
|
||||
self.artist = artist
|
||||
super.init(name: name)
|
||||
}
|
||||
}
|
||||
|
||||
最后一个代码段创建了一个array常量 `library` ,包含两个`Movie`实例和三个`Song`实例。`library`的类型是在它被初始化时根据它的array标记符和里面的内容(ps: literal: 标记符其实就是指“[”和“]”,虽然苹果官方的翻译里翻译为字面当总感觉不好理解,有点奇怪。不如翻译为标记符)推断来的。Swift的类型检测器能够演绎出`Movie` 和 `Song` 有共同的父类 `MediaItem` ,所以它推断出 `MediaItem[]` 类作为 `library` 的类型。
|
||||
|
||||
The final snippet creates a constant array called `library`, which contains two `Movie` instances and three `Song` instances. The type of the `library` array is inferred by initializing it with the contents of an array literal. Swift’s type checker is able to deduce that `Movie` and `Song` have a common superclass of `MediaItem`, and so it infers a type of `MediaItem[]` for the `library` array:
|
||||
|
||||
let library = [
|
||||
Movie(name: "Casablanca", director: "Michael Curtiz"),
|
||||
Song(name: "Blue Suede Shoes", artist: "Elvis Presley"),
|
||||
Movie(name: "Citizen Kane", director: "Orson Welles"),
|
||||
Song(name: "The One And Only", artist: "Chesney Hawkes"),
|
||||
Song(name: "Never Gonna Give You Up", artist: "Rick Astley")
|
||||
]
|
||||
// the type of "library" is inferred to be MediaItem[]
|
||||
|
||||
在幕后`library` 里存储的项依然是 `Movie` 和 `Song` 类型的,但是,若你迭代它,取出的实例会是 `MediaItem` 类型的,而不是 `Movie` 和 `Song` 类型的。为了让它们作为它们本来的类型工作,你需要检查它们的类型或者向下转换它们的类型到其它类型,就像下面描述的一样。
|
||||
|
||||
The items stored in `library` are still `Movie` and `Song` instances behind the scenes. However, if you iterate over the contents of this array, the items you receive back are typed as `MediaItem`, and not as `Movie` or `Song`. In order to work with them as their native type, you need to _check_ their type, or _downcast_ them to a different type, as described below.
|
||||
|
||||
### 检查类型 Checking Type
|
||||
|
||||
用类型检查操作符(`is`)来检查一个实例是否属于特定子类型。类型检查操作符返回 `true` 若实例属于那个子类型,若不属于返回 `false` 。
|
||||
|
||||
Use the _type check operator_ (`is`) to check whether an instance is of a certain subclass type. The type check operator returns `true` if the instance is of that subclass type and `false` if it is not.
|
||||
|
||||
下面的例子定义了连个变量,`movieCount` 和 `songCount`,用来计算数组`library` 中 `Movie` 和 `Song` 类型的实例数量。
|
||||
|
||||
The example below defines two variables, `movieCount` and `songCount`, which count the number of `Movie` and `Song` instances in the `library` array:
|
||||
|
||||
var movieCount = 0
|
||||
var songCount = 0
|
||||
|
||||
for item in library {
|
||||
if item is Movie {
|
||||
++movieCount
|
||||
} else if item is Song {
|
||||
++songCount
|
||||
}
|
||||
}
|
||||
|
||||
println("Media library contains \(movieCount) movies and \(songCount) songs")
|
||||
// prints "Media library contains 2 movies and 3 songs"
|
||||
|
||||
示例迭代了数组 `library` 中的所有项。每一次, `for`-`in` 循环设置
|
||||
`item` 常量的值为数组中的下一个 `MediaItem`。
|
||||
|
||||
This example iterates through all items in the `library` array. On each pass, the `for`-`in` loop sets the `item` constant to the next `MediaItem` in the array.
|
||||
|
||||
若当前 `MediaItem` 是一个 `Movie` 类型的实例, `item is Movie` 返回 `true`,相反返回 `false`。同样的,`item is Song`检查item是否为`Song`类型的实例。在循环末尾,`movieCount` 和 `songCount`的值就是被找到属于各自的类型的实例数量。
|
||||
|
||||
`item is Movie` returns `true` if the current `MediaItem` is a `Movie` instance and `false` if it is not. Similarly, `item is Song` checks whether the item is a `Song` instance. At the end of the `for`-`in` loop, the values of `movieCount` and `songCount` contain a count of how many `MediaItem` instances were found of each type.
|
||||
|
||||
### 向下转型(简称下转) Downcasting
|
||||
|
||||
某类型的一个常量或变量可能在幕后实际上属于一个子类。你可以相信,上面就是这种情况。你可以尝试向下转到它的子类型,用类型检查操作符(`as`)
|
||||
|
||||
A constant or variable of a certain class type may actually refer to an instance of a subclass behind the scenes. Where you believe this is the case, you can try to _downcast_ to the subclass type with the _type cast operator_ (`as`).
|
||||
|
||||
因为向下转型可能会失败,类型检查操作符带有两种不同形式。可选形式( optional form) `as?` 返回一个你试图下转成的类型的可选值(optional value)。强制形式 `as` 把试图向下转型和强制解包(force-unwraps)结果作为一个混合动作。
|
||||
|
||||
Because downcasting can fail, the type cast operator comes in two different forms. The optional form, `as?`, returns an optional value of the type you are trying to downcast to. The forced form, `as`, attempts the downcast and force-unwraps the result as a single compound action.
|
||||
|
||||
当你不确定下转可以成功时,用类型检查的可选形式(`as?`)。可选形式的类型检查总是返回一个可选值(optional value),并且若下转是不可能的,可选值将是 `nil` 。这使你能够检查下转是否成功。
|
||||
|
||||
Use the optional form of the type cast operator (`as?`) when you are not sure if the downcast will succeed. This form of the operator will always return an optional value, and the value will be `nil` if the downcast was not possible. This enables you to check for a successful downcast.
|
||||
|
||||
只有你可以确定下转一定会成功时,才使用强制形式。当你试图下转为一个不正确的类型时,强制形式的类型检查会触发一个runtime error。
|
||||
|
||||
Use the forced form of the type cast operator (`as`) only when you are sure that the downcast will always succeed. This form of the operator will trigger a runtime error if you try to downcast to an incorrect class type.
|
||||
|
||||
下面的例子,迭代了`library`里的每一个 `MediaItem` ,并打印出适当的描述。要这样做,item需要真正作为`Movie` 或 `Song`的类型来使用。不仅仅是作为 `MediaItem`。为了能够使用`Movie` 或 `Song`的 `director` 或 `artist`属性,这是必要的。
|
||||
|
||||
The example below iterates over each `MediaItem` in `library`, and prints an appropriate description for each item. To do this, it needs to access each item as a true `Movie` or `Song`, and not just as a `MediaItem`. This is necessary in order for it to be able to access the `director` or `artist` property of a `Movie` or `Song` for use in the description.
|
||||
|
||||
在这个示例中,数组中的每一个item可能是 `Movie` 或 `Song`。 事前你不知道每个item的真实类型,所以这里使用可选形式的类型检查 (`as?`)去检查循环里的每次下转。
|
||||
|
||||
In this example, each item in the array might be a `Movie`, or it might be a `Song`. You don’t know in advance which actual class to use for each item, and so it is appropriate to use the optional form of the type cast operator (`as?`) to check the downcast each time through the loop:
|
||||
|
||||
for item in library {
|
||||
if let movie = item as? Movie {
|
||||
println("Movie: '\(movie.name)', dir. \(movie.director)")
|
||||
} else if let song = item as? Song {
|
||||
println("Song: '\(song.name)', by \(song.artist)")
|
||||
}
|
||||
}
|
||||
|
||||
// Movie: 'Casablanca', dir. Michael Curtiz
|
||||
// Song: 'Blue Suede Shoes', by Elvis Presley
|
||||
// Movie: 'Citizen Kane', dir. Orson Welles
|
||||
// Song: 'The One And Only', by Chesney Hawkes
|
||||
// Song: 'Never Gonna Give You Up', by Rick Astley
|
||||
|
||||
示例首先试图将 `item` 下转为 `Movie`。因为 `item` 是一个 `MediaItem` 类型的实例,它可能是一个`Movie`;同样,它可能是一个 `Song`,或者仅仅是基类 `MediaItem`。因为不确定,`as?`形式试图下转时返还一个可选值。 `item as Movie` 的返回值是`Movie?`类型或 “optional `Movie`”。
|
||||
|
||||
The example starts by trying to downcast the current `item` as a `Movie`. Because `item` is a `MediaItem` instance, it’s possible that it _might_ be a `Movie`; equally, it’s also possible that it might a `Song`, or even just a base `MediaItem`. Because of this uncertainty, the `as?` form of the type cast operator returns an _optional_ value when attempting to downcast to a subclass type. The result of `item as Movie` is of type `Movie?`, or “optional `Movie`”.
|
||||
|
||||
当应用在两个`Song`实例时,下转为 `Movie` 失败。为了处理这种情况,上面的实例使用了可选绑定(optional binding)来检查optional `Movie`真的包含一个值(这个是为了判断下转是否成功。)可选绑定是这样写的“`if let movie = item as? Movie`”,可以这样解读:
|
||||
|
||||
Downcasting to `Movie` fails when applied to the two `Song` instances in the library array. To cope with this, the example above uses optional binding to check whether the optional `Movie` actually contains a value (that is, to find out whether the downcast succeeded.) This optional binding is written “`if let movie = item as? Movie`”, which can be read as:
|
||||
|
||||
“尝试将 `item` 转为 `Movie`类型。若成功,设置一个新的临时常量 `movie` 来存储返回的optional `Movie`”
|
||||
|
||||
“Try to access `item` as a `Movie`. If this is successful, set a new temporary constant called `movie` to the value stored in the returned optional `Movie`.”
|
||||
|
||||
若下转成功,然后`movie`的属性将用于打印一个`Movie`实例的描述,包括它的导演的名字`director`。当`Song`被找到时,一个相近的原理被用来检测 `Song` 实例和打印它的描述。
|
||||
|
||||
If the downcasting succeeds, the properties of `movie` are then used to print a description for that `Movie` instance, including the name of its `director`. A similar principle is used to check for `Song` instances, and to print an appropriate description (including `artist` name) whenever a `Song` is found in the library.
|
||||
|
||||
注意
|
||||
|
||||
转换没有真的改变实例或它的值。潜在的根本的实例保持不变;只是简单地把它作为它被转换成的类来使用。
|
||||
|
||||
NOTE
|
||||
|
||||
Casting does not actually modify the instance or change its values. The underlying instance remains the same; it is simply treated and accessed as an instance of the type to which it has been cast.
|
||||
|
||||
### Any和AnyObject的转换 Type Casting for Any and AnyObject
|
||||
|
||||
Swift为不确定类型提供了两种特殊类型别名:
|
||||
|
||||
* `AnyObject`可以代表任何class类型的实例。
|
||||
|
||||
* `Any`可以表示任何类型,除了方法类型(function types)。
|
||||
|
||||
Swift provides two special type aliases for working with non-specific types:
|
||||
|
||||
* `AnyObject` can represent an instance of any class type.
|
||||
* `Any` can represent an instance of any type at all, apart from function types.
|
||||
|
||||
注意
|
||||
|
||||
只有当你明确的需要它的行为和功能时才使用Any和AnyObject。在你的代码里使用你期望的明确的类型总是更好的。
|
||||
|
||||
NOTE
|
||||
|
||||
Use Any and AnyObject only when you explicitly need the behavior and capabilities they provide. It is always better to be specific about the types you expect to work with in your code.
|
||||
|
||||
|
||||
### AnyObject类型
|
||||
|
||||
当需要在工作中使用Cocoa APIs,它一般接收一个`AnyObject[]`类型的数组,或者说“一个任何对象类型的数组”。这是因为OC没有明确的类型化数组。但是,你常常可以确定包含在仅从你知道的API信息提供的这样一个数组中的对象的类型。
|
||||
|
||||
When working with Cocoa APIs, it is common to receive an array with a type of `AnyObject[]`, or “an array of values of any object type”. This is because Objective-C does not have explicitly typed arrays. However, you can often be confident about the type of objects contained in such an array just from the information you know about the API that provided the array.
|
||||
|
||||
在这些情况下,你可以使用强制形式的类型检查(`as`)来下转在数组中的每一项到比 `AnyObject` 更明确的类型,不需要可选解包(optional unwrapping)。
|
||||
|
||||
In these situations, you can use the forced version of the type cast operator (`as`) to downcast each item in the array to a more specific class type than `AnyObject`, without the need for optional unwrapping.
|
||||
|
||||
下面的示例定义了一个 `AnyObject[]` 类型的数组并填入三个`Movie`类型的实例:
|
||||
|
||||
The example below defines an array of type `AnyObject[]` and populates this array with three instances of the `Movie` class:
|
||||
|
||||
let someObjects: AnyObject[] = [
|
||||
Movie(name: "2001: A Space Odyssey", director: "Stanley Kubrick"),
|
||||
Movie(name: "Moon", director: "Duncan Jones"),
|
||||
Movie(name: "Alien", director: "Ridley Scott")
|
||||
]
|
||||
|
||||
因为知道这个数组只包含 `Movie` 实例,你可以直接用(`as`)下转并解包到不可选的`Movie`类型(ps:其实就是我们常用的正常类型,这里是为了和可选类型相对比)。
|
||||
|
||||
Because this array is known to contain only `Movie` instances, you can downcast and unwrap directly to a non-optional `Movie` with the forced version of the type cast operator (`as`):
|
||||
|
||||
for object in someObjects {
|
||||
let movie = object as Movie
|
||||
println("Movie: '\(movie.name)', dir. \(movie.director)")
|
||||
}
|
||||
// Movie: '2001: A Space Odyssey', dir. Stanley Kubrick
|
||||
// Movie: 'Moon', dir. Duncan Jones
|
||||
// Movie: 'Alien', dir. Ridley Scott
|
||||
|
||||
为了变为一个更短的形式,下转`someObjects`类型成功 `Movie[]` 类型代替下转每一项。
|
||||
|
||||
For an even shorter form of this loop, downcast the `someObjects` array to a type of `Movie[]` instead of downcasting each item:
|
||||
|
||||
for movie in someObjects as Movie[] {
|
||||
println("Movie: '\(movie.name)', dir. \(movie.director)")
|
||||
}
|
||||
// Movie: '2001: A Space Odyssey', dir. Stanley Kubrick
|
||||
// Movie: 'Moon', dir. Duncan Jones
|
||||
// Movie: 'Alien', dir. Ridley Scott
|
||||
|
||||
### Any类型
|
||||
|
||||
这里有个示例,使用 `Any` 类型来和混合的不同类型一起工作,包括非class类型。它创建了一个可以存储`Any`类型的数组 `things`。
|
||||
|
||||
Here’s an example of using `Any` to work with a mix of different types, including non-class types. The example creates an array called `things`, which can store values of type `Any`:
|
||||
|
||||
var things = Any[]()
|
||||
|
||||
things.append(0)
|
||||
things.append(0.0)
|
||||
things.append(42)
|
||||
things.append(3.14159)
|
||||
things.append("hello")
|
||||
things.append((3.0, 5.0))
|
||||
things.append(Movie(name: "Ghostbusters", director: "Ivan Reitman"))
|
||||
|
||||
`things` 数组包含两个 `Int` 值,2个 `Double` 值,1个 `String` 值,一个元组 `(Double, Double)` ,Ivan Reitman导演的电影“Ghostbusters”。
|
||||
|
||||
The `things` array contains two `Int` values, two `Double` values, a `String` value, a tuple of type `(Double, Double)`, and the movie “Ghostbusters”, directed by Ivan Reitman.
|
||||
|
||||
你可以在 `switch` `cases`里用`is` 和 `as` 操作符来发觉只知道是 `Any` 或 `AnyObject`的常量或变量的类型。 下面的示例迭代 `things`数组中的每一项的并用`switch`语句查找每一项的类型。这几种`switch`语句的情形绑定它们匹配的值到一个规定类型的常量,让它们可以打印它们的值:
|
||||
|
||||
You can use the `is` and `as` operators in a `switch` statement’s cases to discover the specific type of a constant or variable that is known only to be of type `Any` or `AnyObject`. The example below iterates over the items in the `things` array and queries the type of each item with a `switch` statement. Several of the `switch` statement’s cases bind their matched value to a constant of the specified type to enable its value to be printed:
|
||||
|
||||
for thing in things {
|
||||
switch thing {
|
||||
case 0 as Int:
|
||||
println("zero as an Int")
|
||||
case 0 as Double:
|
||||
println("zero as a Double")
|
||||
case let someInt as Int:
|
||||
println("an integer value of \(someInt)")
|
||||
case let someDouble as Double where someDouble > 0:
|
||||
println("a positive double value of \(someDouble)")
|
||||
case is Double:
|
||||
println("some other double value that I don't want to print")
|
||||
case let someString as String:
|
||||
println("a string value of \"\(someString)\"")
|
||||
case let (x, y) as (Double, Double):
|
||||
println("an (x, y) point at \(x), \(y)")
|
||||
case let movie as Movie:
|
||||
println("a movie called '\(movie.name)', dir. \(movie.director)")
|
||||
default:
|
||||
println("something else")
|
||||
}
|
||||
}
|
||||
|
||||
// zero as an Int
|
||||
// zero as a Double
|
||||
// an integer value of 42
|
||||
// a positive double value of 3.14159
|
||||
// a string value of "hello"
|
||||
// an (x, y) point at 3.0, 5.0
|
||||
// a movie called 'Ghostbusters', dir. Ivan Reitman
|
||||
。
|
||||
|
||||
注意
|
||||
|
||||
在一个switch语句的case中使用强制形式的类型检查操作符(as, 而不是 as?) 来检查和转换到一个规定的类型。在switch case 语句的内容中这种检查总是安全的。
|
||||
|
||||
NOTE
|
||||
|
||||
The cases of a switch statement use the forced version of the type cast operator (as, not as?) to check and cast to a specific type. This check is always safe within the context of a switch case statement.
|
||||
|
||||
Reference in New Issue
Block a user