Skip to content

Commit

Permalink
update 02/01
Browse files Browse the repository at this point in the history
  • Loading branch information
numbbbbb authored and wh1100717 committed Jun 6, 2014
1 parent 4c942ce commit 08b3d21
Show file tree
Hide file tree
Showing 40 changed files with 67 additions and 54 deletions.
4 changes: 2 additions & 2 deletions chapter1/01_swift.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="1.1" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="1.1" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down Expand Up @@ -576,7 +576,7 @@ <h1>

<div class="page-inner">

<section class="normal" id="section-gitbook_5">
<section class="normal" id="section-gitbook_4">

<h1 id="-swift">关于 Swift</h1>
<p>Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用程序。Swift 结合了 C 和 Objective-C 的优点并且不受C的兼容性的限制。Swift 使用安全的编程模式并添加了很多新特性,这将使编程更简单,扩展性更强,也更有趣。除此之外,Swift 还支持人见人爱的 Cocoa 和 Cocoa Touch 框架。拥有了这些特性,Swift将重新定义软件开发。</p>
Expand Down
6 changes: 3 additions & 3 deletions chapter1/02_a_swift_tour.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="1.2" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="1.2" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down Expand Up @@ -576,7 +576,7 @@ <h1>

<div class="page-inner">

<section class="normal" id="section-gitbook_6">
<section class="normal" id="section-gitbook_5">

<h1 id="swift-">Swift 初见</h1>
<p>通常来说,编程语言教程中的第一个程序应该在屏幕上打印“Hello, world”。在 Swift 中,可以用一行代码实现:</p>
Expand Down Expand Up @@ -963,7 +963,7 @@ <h2 id="-">函数和闭包</h2>
<p>练习:给<code>Suit</code>添加一个<code>color</code>方法,对<code>spades</code><code>clubs</code>返回“black”,对<code>hearts</code><code>diamonds</code>返回“red”。</p>
</blockquote>
<p>注意,有两种方式可以引用<code>Hearts</code>成员:给<code>hearts</code>常量赋值时,枚举成员<code>Suit.Hearts</code>需要用全名来引用,因为常量没有显式指定类型。在<code>switch</code>里,枚举成员使用缩写<code>.Hearts</code>来引用,因为<code>self</code>的值已经知道是一个<code>suit</code>。已知变量类型的情况下你可以使用缩写。</p>
<p>使用<code>struct</code>来创建一个结构体。结构体和类有很多相同的地方,比如方法和构造器。它们结构体之间最大的一个区别就是
<p>使用<code>struct</code>来创建一个结构体。结构体和类有很多相同的地方,比如方法和构造器。它们之间最大的一个区别就是
结构体是传值,类是传引用。</p>
<pre><code>struct Card {
var rank: Rank
Expand Down
4 changes: 2 additions & 2 deletions chapter1/chapter1.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="1" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="1" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down Expand Up @@ -576,7 +576,7 @@ <h1>

<div class="page-inner">

<section class="normal" id="section-gitbook_7">
<section class="normal" id="section-gitbook_6">

<h1 id="-swift">欢迎使用 Swift</h1>
<p>在本章中您将了解 Swift 的特性和开发历史,并对 Swift 有一个初步的了解。</p>
Expand Down
25 changes: 19 additions & 6 deletions chapter2/01_The_Basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.1" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.1" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down Expand Up @@ -576,7 +576,7 @@ <h1>

<div class="page-inner">

<section class="normal" id="section-gitbook_9">
<section class="normal" id="section-gitbook_8">

<h1 id="-">基础部分</h1>
<p>Swift 是 iOS 和 OS X 应用开发的一门新语言。然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的。</p>
Expand All @@ -586,18 +586,19 @@ <h1 id="-">基础部分</h1>
<p>Swift 还增加了可选(Optional)类型,用于处理值缺失的情况。可选表示“那儿有一个值,并且它等于 x ”或者“那儿没有值”。可选有点像在 Objective-C 中使用<code>nil</code>,但是它可以用在任何类型上,不仅仅是类。可选类型比 Objective-C 中的<code>nil</code>指针更加安全也更具表现力,它是 Swift 许多强大特性的重要组成部分。</p>
<p>Swift 是一个类型安全的语言,可选就是一个很好的例子。Swift 可以让你清楚地知道值的类型。如果你的代码期望得到一个<code>String</code>,类型安全会阻止你不小心传入一个<code>Int</code>。你可以在开发阶段尽早发现并修正错误。</p>
<h2 id="-">常量和变量</h2>
<p>常量和变量把一个名字(比如<code>maximumNumberOfLoginAttempts</code>或者<code>welcomeMessage</code>)和一个指定类型的值(比如数字<code>10</code>或者字符串<code>Hello</code>联系起来。常量的值一旦设定就不能改变,而变量的值可以随意更改。</p>
<p>常量和变量把一个名字(比如<code>maximumNumberOfLoginAttempts</code>或者<code>welcomeMessage</code>)和一个指定类型的值(比如数字<code>10</code>或者字符串<code>Hello</code>关联起来。常量的值一旦设定就不能改变,而变量的值可以随意更改。</p>
<h3 id="-">声明常量和变量</h3>
<p>常量和变量必须在使用前声明,用<code>let</code>来声明常量,用<code>var</code>来声明变量。下面的例子展示了如何用常量和变量来记录用户尝试登录的次数:</p>
<pre><code>let maximumNumberOfLoginAttempts = 10
var currentLoginAttempt = 0
</code></pre><p>这两行代码可以被理解为:</p>
<p>“声明一个名字是<code>maximumNumberOfLoginAttempts</code>的新常量,并给它一个值<code>10</code>。然后,声明一个名字是<code>currentLoginAttempt</code>的变量并将它的值初始化为0.”</p>
</code></pre><p>这两行代码可以被理解为
“声明一个名字是<code>maximumNumberOfLoginAttempts</code>的新常量,并给它一个值<code>10</code>。然后,声明一个名字是<code>currentLoginAttempt</code>的变量并将它的值初始化为0.”</p>
<p>在这个例子中,允许的最大尝试登录次数被声明为一个常量,因为这个值不会改变。当前尝试登录次数被声明为一个变量,因为每次尝试登录失败的时候都需要增加这个值。</p>
<p>你可以在一行中声明多个常量或者多个变量,用逗号隔开:</p>
<pre><code>var x = 0.0, y = 0.0, z = 0.0
</code></pre><blockquote>
<p>注意:如果你的代码中有不需要改变的值,最好将它声明为常量。只将需要改变的值声明为变量。</p>
<p>注意:如果你的代码中有不需要改变的值,请将它声明为常量。只将需要改变的值声明为变量。</p>
</blockquote>
<h3 id="-">类型标注</h3>
<p>当你声明常量或者变量的时候可以加上类型标注,说明常量或者变量中要存储的值的类型。如果要添加类型标注,在常量或者变量名后面加上一个冒号和空格,然后加上类型名称。</p>
Expand Down Expand Up @@ -644,6 +645,18 @@ <h3 id="-">常量和变量的命名</h3>
</code></pre><blockquote>
<p>注意:字符串插值所有可用的选项在 字符串插值 这章中讲述。</p>
</blockquote>
<h3 id="-">注释</h3>
<p>请将你的代码中的非执行文本注释成提示或者笔记以方便你将来阅读。Swift 的编译器将会在编译代码时自动忽略掉注释部分。</p>
<p>Swift 中的注释与C 语言的注释非常相似。单行注释以双正斜杠作(//)为起始标记:</p>
<pre><code>// this is a comment
</code></pre><p>你也可以进行多行注释,其起始标记为单个正斜杠后跟随一个星号(/<em>),终止标记为一个星号后跟随单个正斜杠(\</em>/):</p>
<pre><code>/* this is also a comment,
but written over multiple lines */
</code></pre><p>与C 语言多行注释不同的是,Swift 的多行注释可以嵌套在其它的多行注释之中。你可以先生成一个多行注释块,然后在这个注释块之中再嵌套成第二个多行注释。终止注释时先插入第二个注释块的终止标记,然后再插入第一个注释块的终止标记:</p>
<pre><code>/* this is the start of the first multiline comment
/* this is the second, nested multiline comment */
this is the end of the first multiline comment */
</code></pre><p>通过运用嵌套多行注释,你可以快速方便的注释掉一大段代码,即使这段代码之中已经含有了多行注释块。</p>


</section>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/02_Basic_Operators.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.2" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.2" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
4 changes: 2 additions & 2 deletions chapter2/03_Strings_and_Characters.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.3" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.3" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down Expand Up @@ -576,7 +576,7 @@ <h1>

<div class="page-inner">

<section class="normal" id="section-gitbook_10">
<section class="normal" id="section-gitbook_9">

<h1 id="-strings-and-characters-">字符串和字符 (Strings and Characters)</h1>
<p><strong>String</strong> 是一个有序的字符集合,例如 &quot;hello, world&quot;, &quot;albatross&quot;。Swift 字符串通过 <strong>String</strong> 类型来表示,也可以表示为 <strong>Character</strong> 类型值的集合。</p>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/04_Collection_Types.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.4" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.4" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/05_Control_Flow.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.5" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.5" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
4 changes: 2 additions & 2 deletions chapter2/06_Functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.6" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.6" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down Expand Up @@ -576,7 +576,7 @@ <h1>

<div class="page-inner">

<section class="normal" id="section-gitbook_13">
<section class="normal" id="section-gitbook_12">

<h1 id="-functions-">函数(Functions)</h1>
<p>函数是用来完成特定任务的独立的代码块。你给一个函数起一个合适的名字,用来标示函数做什么,并且当函数需要执行的时候,这个名字会被“调用”。</p>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/07_Closures.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.7" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.7" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/08_Enumerations.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.8" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.8" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/09_Classes_and_Structures.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.9" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.9" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/10_Properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.10" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.10" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/11_Methods.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.11" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.11" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/12_Subscripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.12" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.12" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/13_Inheritance.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.13" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.13" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/14_Initialization.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.14" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.14" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/15_Deinitialization.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.15" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.15" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/16_Automatic_Reference_Counting.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.16" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.16" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/17_Optional_Chaining.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.17" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.17" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/18_Type_Casting.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.18" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.18" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/19_Nested_Types.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.19" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.19" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/20_Extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.20" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.20" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/21_Protocols.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.21" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.21" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/22_Generics.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.22" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.22" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
2 changes: 1 addition & 1 deletion chapter2/23_Advanced_Operators.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2.23" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2.23" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down
4 changes: 2 additions & 2 deletions chapter2/chapter2.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@



<div class="book" data-level="2" data-basepath=".." data-revision="1401935155501">
<div class="book" data-level="2" data-basepath=".." data-revision="1401943865087">
<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>
Expand Down Expand Up @@ -576,7 +576,7 @@ <h1>

<div class="page-inner">

<section class="normal" id="section-gitbook_31">
<section class="normal" id="section-gitbook_30">

<h1 id="swift-">Swift 教程</h1>
<p>本章介绍了 Swift 的各种特性及其使用方法,是全书的核心部分。</p>
Expand Down
Loading

0 comments on commit 08b3d21

Please sign in to comment.