add the space between chinese and english words

This commit is contained in:
numbbbbb
2014-06-04 19:39:01 +08:00
parent 756523991f
commit 08ec0ce655
15 changed files with 158 additions and 156 deletions

View File

@ -5,12 +5,12 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>欢迎使用Swift | Swift编程语言</title> <title>欢迎使用 Swift | Swift 编程语言</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="robots" content="index, follow"> <meta name="robots" content="index, follow">
<meta name="author" content=""> <meta name="author" content="">
<meta name="description" content="Swift是苹果在WWDC2014上发布的一款全新的编程语言本书译自苹果官方的Swift教程《The Swift Programming Language》。"> <meta name="description" content="Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。">
<meta name="keywords" content="gitbook,github" > <meta name="keywords" content="gitbook,github" >
<meta name="generator" content="www.gitbook.io"> <meta name="generator" content="www.gitbook.io">
@ -21,8 +21,8 @@
<link rel="prev" href="../index.html" /> <link rel="prev" href="../index.html" />
<meta property="og:title" content="欢迎使用Swift | Swift编程语言"> <meta property="og:title" content="欢迎使用 Swift | Swift 编程语言">
<meta property="og:site_name" content="Swift编程语言"> <meta property="og:site_name" content="Swift 编程语言">
<meta property="og:type" content="book"> <meta property="og:type" content="book">
<meta property="og:locale" content="en_US"> <meta property="og:locale" content="en_US">
@ -46,7 +46,7 @@
<div class="book" data-level="1" data-basepath=".." data-revision="1401879002086"> <div class="book" data-level="1" data-basepath=".." data-revision="1401881908280">
<div class="book-header"> <div class="book-header">
<!-- Actions Left --> <!-- Actions Left -->
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a> <a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
@ -98,7 +98,7 @@
<!-- Title --> <!-- Title -->
<h1> <h1>
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin"></i>
<a href="../" >Swift编程语言</a> <a href="../" >Swift 编程语言</a>
</h1> </h1>
</div> </div>
@ -126,7 +126,7 @@
<li class="chapter " data-level="1" data-path="chapter1/README.html"> <li class="chapter " data-level="1" data-path="chapter1/README.html">
<a href="../chapter1/README.html"> <a href="../chapter1/README.html">
<i class="fa fa-check"></i> <b>1.</b> 欢迎使用Swift <i class="fa fa-check"></i> <b>1.</b> 欢迎使用 Swift
</a> </a>
@ -136,7 +136,7 @@
<li class="chapter " data-level="1.1" data-path="chapter1/swift.html"> <li class="chapter " data-level="1.1" data-path="chapter1/swift.html">
<a href="../chapter1/swift.html"> <a href="../chapter1/swift.html">
<i class="fa fa-check"></i> <b>1.1.</b> 关于Swift <i class="fa fa-check"></i> <b>1.1.</b> 关于 Swift
</a> </a>
@ -145,7 +145,7 @@
<li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html"> <li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html">
<a href="../chapter1/a_swift_tour.html"> <a href="../chapter1/a_swift_tour.html">
<i class="fa fa-check"></i> <b>1.2.</b> Swift初见 <i class="fa fa-check"></i> <b>1.2.</b> Swift 初见
</a> </a>
@ -159,7 +159,7 @@
<li class="chapter " data-level="2" data-path="chapter2/the_basics.html"> <li class="chapter " data-level="2" data-path="chapter2/the_basics.html">
<a href="../chapter2/the_basics.html"> <a href="../chapter2/the_basics.html">
<i class="fa fa-check"></i> <b>2.</b> Swift教程 <i class="fa fa-check"></i> <b>2.</b> Swift 教程
</a> </a>
@ -202,13 +202,13 @@
<a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a> <a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a>
<a href="../chapter1/README.html" title="欢迎使用Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a> <a href="../chapter1/README.html" title="欢迎使用 Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a>
<a href="../chapter1/swift.html" title="关于Swift" class="chapter " data-progress="1.1" style="left: 40%;"></a> <a href="../chapter1/swift.html" title="关于 Swift" class="chapter " data-progress="1.1" style="left: 40%;"></a>
<a href="../chapter1/a_swift_tour.html" title="Swift初见" class="chapter " data-progress="1.2" style="left: 60%;"></a> <a href="../chapter1/a_swift_tour.html" title="Swift 初见" class="chapter " data-progress="1.2" style="left: 60%;"></a>
<a href="../chapter2/the_basics.html" title="Swift教程" class="chapter new-chapter" data-progress="2" style="left: 80%;"></a> <a href="../chapter2/the_basics.html" title="Swift 教程" class="chapter new-chapter" data-progress="2" style="left: 80%;"></a>
<a href="../chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a> <a href="../chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a>
@ -217,10 +217,10 @@
<div class="page-inner"> <div class="page-inner">
<section class="normal" id="section-gitbook_7"> <section class="normal" id="section-gitbook_141">
<h1 id="-swift">欢迎使用Swift</h1> <h1 id="-swift">欢迎使用 Swift</h1>
<p>在本章中您将了解Swift的特性和开发历史并对Swift有一个初步的了解。</p> <p>在本章中您将了解 Swift 的特性和开发历史,并对 Swift 有一个初步的了解。</p>
</section> </section>
@ -233,7 +233,7 @@
<a href="../index.html" class="navigation navigation-prev " aria-label="Previous page: Introduction"><i class="fa fa-angle-left"></i></a> <a href="../index.html" class="navigation navigation-prev " aria-label="Previous page: Introduction"><i class="fa fa-angle-left"></i></a>
<a href="../chapter1/swift.html" class="navigation navigation-next " aria-label="Next page: 关于Swift"><i class="fa fa-angle-right"></i></a> <a href="../chapter1/swift.html" class="navigation navigation-next " aria-label="Next page: 关于 Swift"><i class="fa fa-angle-right"></i></a>
</div> </div>
</div> </div>

View File

@ -5,12 +5,12 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Swift初见 | Swift编程语言</title> <title>Swift 初见 | Swift 编程语言</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="robots" content="index, follow"> <meta name="robots" content="index, follow">
<meta name="author" content=""> <meta name="author" content="">
<meta name="description" content="Swift是苹果在WWDC2014上发布的一款全新的编程语言本书译自苹果官方的Swift教程《The Swift Programming Language》。"> <meta name="description" content="Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。">
<meta name="keywords" content="gitbook,github" > <meta name="keywords" content="gitbook,github" >
<meta name="generator" content="www.gitbook.io"> <meta name="generator" content="www.gitbook.io">
@ -21,8 +21,8 @@
<link rel="prev" href="../chapter1/swift.html" /> <link rel="prev" href="../chapter1/swift.html" />
<meta property="og:title" content="Swift初见 | Swift编程语言"> <meta property="og:title" content="Swift 初见 | Swift 编程语言">
<meta property="og:site_name" content="Swift编程语言"> <meta property="og:site_name" content="Swift 编程语言">
<meta property="og:type" content="book"> <meta property="og:type" content="book">
<meta property="og:locale" content="en_US"> <meta property="og:locale" content="en_US">
@ -46,7 +46,7 @@
<div class="book" data-level="1.2" data-basepath=".." data-revision="1401879002086"> <div class="book" data-level="1.2" data-basepath=".." data-revision="1401881908280">
<div class="book-header"> <div class="book-header">
<!-- Actions Left --> <!-- Actions Left -->
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a> <a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
@ -98,7 +98,7 @@
<!-- Title --> <!-- Title -->
<h1> <h1>
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin"></i>
<a href="../" >Swift编程语言</a> <a href="../" >Swift 编程语言</a>
</h1> </h1>
</div> </div>
@ -126,7 +126,7 @@
<li class="chapter " data-level="1" data-path="chapter1/README.html"> <li class="chapter " data-level="1" data-path="chapter1/README.html">
<a href="../chapter1/README.html"> <a href="../chapter1/README.html">
<i class="fa fa-check"></i> <b>1.</b> 欢迎使用Swift <i class="fa fa-check"></i> <b>1.</b> 欢迎使用 Swift
</a> </a>
@ -136,7 +136,7 @@
<li class="chapter " data-level="1.1" data-path="chapter1/swift.html"> <li class="chapter " data-level="1.1" data-path="chapter1/swift.html">
<a href="../chapter1/swift.html"> <a href="../chapter1/swift.html">
<i class="fa fa-check"></i> <b>1.1.</b> 关于Swift <i class="fa fa-check"></i> <b>1.1.</b> 关于 Swift
</a> </a>
@ -145,7 +145,7 @@
<li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html"> <li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html">
<a href="../chapter1/a_swift_tour.html"> <a href="../chapter1/a_swift_tour.html">
<i class="fa fa-check"></i> <b>1.2.</b> Swift初见 <i class="fa fa-check"></i> <b>1.2.</b> Swift 初见
</a> </a>
@ -159,7 +159,7 @@
<li class="chapter " data-level="2" data-path="chapter2/the_basics.html"> <li class="chapter " data-level="2" data-path="chapter2/the_basics.html">
<a href="../chapter2/the_basics.html"> <a href="../chapter2/the_basics.html">
<i class="fa fa-check"></i> <b>2.</b> Swift教程 <i class="fa fa-check"></i> <b>2.</b> Swift 教程
</a> </a>
@ -202,13 +202,13 @@
<a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a> <a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a>
<a href="../chapter1/README.html" title="欢迎使用Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a> <a href="../chapter1/README.html" title="欢迎使用 Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a>
<a href="../chapter1/swift.html" title="关于Swift" class="chapter done " data-progress="1.1" style="left: 40%;"></a> <a href="../chapter1/swift.html" title="关于 Swift" class="chapter done " data-progress="1.1" style="left: 40%;"></a>
<a href="../chapter1/a_swift_tour.html" title="Swift初见" class="chapter done " data-progress="1.2" style="left: 60%;"></a> <a href="../chapter1/a_swift_tour.html" title="Swift 初见" class="chapter done " data-progress="1.2" style="left: 60%;"></a>
<a href="../chapter2/the_basics.html" title="Swift教程" class="chapter new-chapter" data-progress="2" style="left: 80%;"></a> <a href="../chapter2/the_basics.html" title="Swift 教程" class="chapter new-chapter" data-progress="2" style="left: 80%;"></a>
<a href="../chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a> <a href="../chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a>
@ -217,15 +217,15 @@
<div class="page-inner"> <div class="page-inner">
<section class="normal" id="section-gitbook_8"> <section class="normal" id="section-gitbook_142">
<h1 id="swift-">Swift初见</h1> <h1 id="swift-">Swift 初见</h1>
<p>通常来说编程语言教程中的第一个程序应该在屏幕上打印“Hello, world”。在Swift中可以用一行代码实现</p> <p>通常来说编程语言教程中的第一个程序应该在屏幕上打印“Hello, world”。在 Swift 中,可以用一行代码实现:</p>
<pre><code>println(&quot;hello, world&quot;) <pre><code>println(&quot;hello, world&quot;)
</code></pre><p>如果你写过C或者Objective-C代码那你应该很熟悉这种形式——在Swift中这行代码就是一个完整的程序。你不需要为了输入输出或者字符串处理导入一个单独的库。全局作用域中的代码会被自动当做程序的入口点所以你也不需要<code>main</code>函数。你同样不需要在每个语句结尾写上分号。</p> </code></pre><p>如果你写过 C 或者 Objective-C 代码,那你应该很熟悉这种形式——在 Swift 中,这行代码就是一个完整的程序。你不需要为了输入输出或者字符串处理导入一个单独的库。全局作用域中的代码会被自动当做程序的入口点,所以你也不需要<code>main</code>函数。你同样不需要在每个语句结尾写上分号。</p>
<p>这个教程会通过一系列编程例子来让你对Swift有初步了解如果你有什么不理解的地方也不用担心——任何本章介绍的内容都会在后面的章节中详细讲解。</p> <p>这个教程会通过一系列编程例子来让你对 Swift 有初步了解,如果你有什么不理解的地方也不用担心——任何本章介绍的内容都会在后面的章节中详细讲解。</p>
<blockquote> <blockquote>
<p>注意为了获得最好的体验在Xcode当中使用代码预览功能。代码预览功能可以让你编辑代码并实时看到运行结果。</p> <p>注意:为了获得最好的体验,在 Xcode 当中使用代码预览功能。代码预览功能可以让你编辑代码并实时看到运行结果。</p>
</blockquote> </blockquote>
<h2 id="-">简单值</h2> <h2 id="-">简单值</h2>
<p>使用<code>let</code>来声明常量,使用<code>var</code>来声明变量。一个常量的值在编译时并不需要获取,但是你只能为它赋值一次。也就是说你可以用常量来表示这样一个值:你只需要决定一次,但是需要使用很多次。</p> <p>使用<code>let</code>来声明常量,使用<code>var</code>来声明变量。一个常量的值在编译时并不需要获取,但是你只能为它赋值一次。也就是说你可以用常量来表示这样一个值:你只需要决定一次,但是需要使用很多次。</p>
@ -481,7 +481,7 @@ test.simpleDescription()
</code></pre><blockquote> </code></pre><blockquote>
<p>练习:创建<code>NamedShape</code>的另一个子类<code>Circle</code>,构造器接收两个参数,一个是半径一个是名称,实现<code>area</code><code>describe</code>方法。</p> <p>练习:创建<code>NamedShape</code>的另一个子类<code>Circle</code>,构造器接收两个参数,一个是半径一个是名称,实现<code>area</code><code>describe</code>方法。</p>
</blockquote> </blockquote>
<p>属性可以有gettersetter。</p> <p>属性可以有 gettersetter </p>
<pre><code>class EquilateralTriangle: NamedShape { <pre><code>class EquilateralTriangle: NamedShape {
var sideLength: Double = 0.0 var sideLength: Double = 0.0
@ -508,7 +508,7 @@ var triangle = EquilateralTriangle(sideLength: 3.1, name: &quot;a triangle&quot;
triangle.perimeter triangle.perimeter
triangle.perimeter = 9.9 triangle.perimeter = 9.9
triangle.sideLength triangle.sideLength
</code></pre><p><code>perimeter</code>的setter中新值的名字是<code>newValue</code>。你可以在<code>set</code>之后显示的设置一个名字。</p> </code></pre><p><code>perimeter</code> setter 中,新值的名字是<code>newValue</code>。你可以在<code>set</code>之后显示的设置一个名字。</p>
<p>注意<code>EquilateralTriangle</code>类的构造器执行了三步:</p> <p>注意<code>EquilateralTriangle</code>类的构造器执行了三步:</p>
<ol> <ol>
<li>设置子类声明的属性值</li> <li>设置子类声明的属性值</li>
@ -731,10 +731,10 @@ anyCommonElements([1, 2, 3], [3])
</div> </div>
<a href="../chapter1/swift.html" class="navigation navigation-prev " aria-label="Previous page: 关于Swift"><i class="fa fa-angle-left"></i></a> <a href="../chapter1/swift.html" class="navigation navigation-prev " aria-label="Previous page: 关于 Swift"><i class="fa fa-angle-left"></i></a>
<a href="../chapter2/the_basics.html" class="navigation navigation-next " aria-label="Next page: Swift教程"><i class="fa fa-angle-right"></i></a> <a href="../chapter2/the_basics.html" class="navigation navigation-next " aria-label="Next page: Swift 教程"><i class="fa fa-angle-right"></i></a>
</div> </div>
</div> </div>

View File

@ -5,12 +5,12 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>关于Swift | Swift编程语言</title> <title>关于 Swift | Swift 编程语言</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="robots" content="index, follow"> <meta name="robots" content="index, follow">
<meta name="author" content=""> <meta name="author" content="">
<meta name="description" content="Swift是苹果在WWDC2014上发布的一款全新的编程语言本书译自苹果官方的Swift教程《The Swift Programming Language》。"> <meta name="description" content="Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。">
<meta name="keywords" content="gitbook,github" > <meta name="keywords" content="gitbook,github" >
<meta name="generator" content="www.gitbook.io"> <meta name="generator" content="www.gitbook.io">
@ -21,8 +21,8 @@
<link rel="prev" href="../chapter1/README.html" /> <link rel="prev" href="../chapter1/README.html" />
<meta property="og:title" content="关于Swift | Swift编程语言"> <meta property="og:title" content="关于 Swift | Swift 编程语言">
<meta property="og:site_name" content="Swift编程语言"> <meta property="og:site_name" content="Swift 编程语言">
<meta property="og:type" content="book"> <meta property="og:type" content="book">
<meta property="og:locale" content="en_US"> <meta property="og:locale" content="en_US">
@ -46,7 +46,7 @@
<div class="book" data-level="1.1" data-basepath=".." data-revision="1401879002086"> <div class="book" data-level="1.1" data-basepath=".." data-revision="1401881908280">
<div class="book-header"> <div class="book-header">
<!-- Actions Left --> <!-- Actions Left -->
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a> <a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
@ -98,7 +98,7 @@
<!-- Title --> <!-- Title -->
<h1> <h1>
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin"></i>
<a href="../" >Swift编程语言</a> <a href="../" >Swift 编程语言</a>
</h1> </h1>
</div> </div>
@ -126,7 +126,7 @@
<li class="chapter " data-level="1" data-path="chapter1/README.html"> <li class="chapter " data-level="1" data-path="chapter1/README.html">
<a href="../chapter1/README.html"> <a href="../chapter1/README.html">
<i class="fa fa-check"></i> <b>1.</b> 欢迎使用Swift <i class="fa fa-check"></i> <b>1.</b> 欢迎使用 Swift
</a> </a>
@ -136,7 +136,7 @@
<li class="chapter " data-level="1.1" data-path="chapter1/swift.html"> <li class="chapter " data-level="1.1" data-path="chapter1/swift.html">
<a href="../chapter1/swift.html"> <a href="../chapter1/swift.html">
<i class="fa fa-check"></i> <b>1.1.</b> 关于Swift <i class="fa fa-check"></i> <b>1.1.</b> 关于 Swift
</a> </a>
@ -145,7 +145,7 @@
<li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html"> <li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html">
<a href="../chapter1/a_swift_tour.html"> <a href="../chapter1/a_swift_tour.html">
<i class="fa fa-check"></i> <b>1.2.</b> Swift初见 <i class="fa fa-check"></i> <b>1.2.</b> Swift 初见
</a> </a>
@ -159,7 +159,7 @@
<li class="chapter " data-level="2" data-path="chapter2/the_basics.html"> <li class="chapter " data-level="2" data-path="chapter2/the_basics.html">
<a href="../chapter2/the_basics.html"> <a href="../chapter2/the_basics.html">
<i class="fa fa-check"></i> <b>2.</b> Swift教程 <i class="fa fa-check"></i> <b>2.</b> Swift 教程
</a> </a>
@ -202,13 +202,13 @@
<a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a> <a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a>
<a href="../chapter1/README.html" title="欢迎使用Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a> <a href="../chapter1/README.html" title="欢迎使用 Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a>
<a href="../chapter1/swift.html" title="关于Swift" class="chapter done " data-progress="1.1" style="left: 40%;"></a> <a href="../chapter1/swift.html" title="关于 Swift" class="chapter done " data-progress="1.1" style="left: 40%;"></a>
<a href="../chapter1/a_swift_tour.html" title="Swift初见" class="chapter " data-progress="1.2" style="left: 60%;"></a> <a href="../chapter1/a_swift_tour.html" title="Swift 初见" class="chapter " data-progress="1.2" style="left: 60%;"></a>
<a href="../chapter2/the_basics.html" title="Swift教程" class="chapter new-chapter" data-progress="2" style="left: 80%;"></a> <a href="../chapter2/the_basics.html" title="Swift 教程" class="chapter new-chapter" data-progress="2" style="left: 80%;"></a>
<a href="../chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a> <a href="../chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a>
@ -217,15 +217,15 @@
<div class="page-inner"> <div class="page-inner">
<section class="normal" id="section-gitbook_9"> <section class="normal" id="section-gitbook_143">
<h1 id="-swift">关于Swift</h1> <h1 id="-swift">关于 Swift</h1>
<p>Swift是一种新的编程语言用于编写iOSOS X应用程序。Swift结合了C和Objective-C的优点并且不受C的兼容性的限制。Swift使用安全的编程模式并添加了很多新特性这将使编程更简单扩展性更强也更有趣。除此之外Swift还支持人见人爱的CocoaCocoa Touch框架。拥有了这些特性Swift将重新定义软件开发。</p> <p>Swift 是一种新的编程语言,用于编写 iOSOS X 应用程序。Swift 结合了 C 和 Objective-C 的优点并且不受C的兼容性的限制。Swift 使用安全的编程模式并添加了很多新特性这将使编程更简单扩展性更强也更有趣。除此之外Swift 还支持人见人爱的 CocoaCocoa Touch 框架。拥有了这些特性Swift将重新定义软件开发。</p>
<p>Swift的开发从很久之前就开始了。为了给Swift打好基础苹果公司改进了编译器调试器和框架结构。我们使用自动引用计数Automatic Reference Counting, ARC来简化内存管理。我们在FoundationCocoa的基础上构建框架栈并将其标准化。Objective-C本身支持块、集合语法和模块所以框架可以轻松支持现代编程语言技术。得益于这些基础工作我们现在可以发布一个新语言用于未来的苹果软件的开发。</p> <p>Swift 的开发从很久之前就开始了。为了给 Swift 打好基础苹果公司改进了编译器调试器和框架结构。我们使用自动引用计数Automatic Reference Counting, ARC来简化内存管理。我们在 FoundationCocoa的基础上构建框架栈并将其标准化。Objective-C 本身支持块、集合语法和模块,所以框架可以轻松支持现代编程语言技术。得益于这些基础工作,我们现在可以发布一个新语言,用于未来的苹果软件的开发。</p>
<p>Objective-C开发者对于Swift并不会感到陌生。它采用了Objective-C的命名参数以及动态对象模型可以无缝对接到现有的Cocoa框架并且可以兼容Objective-C代码。在此基础之上Swift还有许多新特性并且支持过程式编程和面向对象编程。</p> <p>Objective-C 开发者对于 Swift 并不会感到陌生。它采用了 Objective-C 的命名参数以及动态对象模型,可以无缝对接到现有的 Cocoa 框架,并且可以兼容 Objective-C 代码。在此基础之上Swift 还有许多新特性并且支持过程式编程和面向对象编程。</p>
<p>Swift对于初学者来说也很友好。它是第一个既满足工业标准又像脚本语言一样充满表现力和趣味的编程语言。它支持代码预览这个革命性的特性可以允许程序员在不编译和运行应用程序的前提下运行Swift代码并实时查看结果。</p> <p>Swift 对于初学者来说也很友好。它是第一个既满足工业标准又像脚本语言一样充满表现力和趣味的编程语言。它支持代码预览,这个革命性的特性可以允许程序员在不编译和运行应用程序的前提下运行 Swift 代码并实时查看结果。</p>
<p>Swift将现代编程语言的精华和苹果工程师文化的智慧结合了起来。编译器对性能进行了优化编程语言对开发进行了优化两者互不干扰鱼与熊掌兼得。Swift即可以用于开发“hello, world”这样的小程序也可以用于开发一个完整的操作系统。所有的这些特性让Swift对于开发者和苹果来说都是一项值得的投资。</p> <p>Swift 将现代编程语言的精华和苹果工程师文化的智慧结合了起来。编译器对性能进行了优化编程语言对开发进行了优化两者互不干扰鱼与熊掌兼得。Swift 即可以用于开发“hello, world”这样的小程序也可以用于开发一个完整的操作系统。所有的这些特性让 Swift 对于开发者和苹果来说都是一项值得的投资。</p>
<p>用Swift编写iOSOS X应用将是一场美妙的体验Swift之后也会不断开发新特性和兼容性。我们对Swift充满信心你还在等什么</p> <p> Swift 编写 iOSOS X 应用将是一场美妙的体验Swift 之后也会不断开发新特性和兼容性。我们对 Swift 充满信心,你还在等什么!</p>
</section> </section>
@ -235,10 +235,10 @@
</div> </div>
<a href="../chapter1/README.html" class="navigation navigation-prev " aria-label="Previous page: 欢迎使用Swift"><i class="fa fa-angle-left"></i></a> <a href="../chapter1/README.html" class="navigation navigation-prev " aria-label="Previous page: 欢迎使用 Swift"><i class="fa fa-angle-left"></i></a>
<a href="../chapter1/a_swift_tour.html" class="navigation navigation-next " aria-label="Next page: Swift初见"><i class="fa fa-angle-right"></i></a> <a href="../chapter1/a_swift_tour.html" class="navigation navigation-next " aria-label="Next page: Swift 初见"><i class="fa fa-angle-right"></i></a>
</div> </div>
</div> </div>

View File

@ -5,12 +5,12 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>基础部分 | Swift编程语言</title> <title>基础部分 | Swift 编程语言</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="robots" content="index, follow"> <meta name="robots" content="index, follow">
<meta name="author" content=""> <meta name="author" content="">
<meta name="description" content="Swift是苹果在WWDC2014上发布的一款全新的编程语言本书译自苹果官方的Swift教程《The Swift Programming Language》。"> <meta name="description" content="Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。">
<meta name="keywords" content="gitbook,github" > <meta name="keywords" content="gitbook,github" >
<meta name="generator" content="www.gitbook.io"> <meta name="generator" content="www.gitbook.io">
@ -19,8 +19,8 @@
<link rel="prev" href="../chapter2/the_basics.html" /> <link rel="prev" href="../chapter2/the_basics.html" />
<meta property="og:title" content="基础部分 | Swift编程语言"> <meta property="og:title" content="基础部分 | Swift 编程语言">
<meta property="og:site_name" content="Swift编程语言"> <meta property="og:site_name" content="Swift 编程语言">
<meta property="og:type" content="book"> <meta property="og:type" content="book">
<meta property="og:locale" content="en_US"> <meta property="og:locale" content="en_US">
@ -44,7 +44,7 @@
<div class="book" data-level="2.1" data-basepath=".." data-revision="1401879002086"> <div class="book" data-level="2.1" data-basepath=".." data-revision="1401881908280">
<div class="book-header"> <div class="book-header">
<!-- Actions Left --> <!-- Actions Left -->
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a> <a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
@ -96,7 +96,7 @@
<!-- Title --> <!-- Title -->
<h1> <h1>
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin"></i>
<a href="../" >Swift编程语言</a> <a href="../" >Swift 编程语言</a>
</h1> </h1>
</div> </div>
@ -124,7 +124,7 @@
<li class="chapter " data-level="1" data-path="chapter1/README.html"> <li class="chapter " data-level="1" data-path="chapter1/README.html">
<a href="../chapter1/README.html"> <a href="../chapter1/README.html">
<i class="fa fa-check"></i> <b>1.</b> 欢迎使用Swift <i class="fa fa-check"></i> <b>1.</b> 欢迎使用 Swift
</a> </a>
@ -134,7 +134,7 @@
<li class="chapter " data-level="1.1" data-path="chapter1/swift.html"> <li class="chapter " data-level="1.1" data-path="chapter1/swift.html">
<a href="../chapter1/swift.html"> <a href="../chapter1/swift.html">
<i class="fa fa-check"></i> <b>1.1.</b> 关于Swift <i class="fa fa-check"></i> <b>1.1.</b> 关于 Swift
</a> </a>
@ -143,7 +143,7 @@
<li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html"> <li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html">
<a href="../chapter1/a_swift_tour.html"> <a href="../chapter1/a_swift_tour.html">
<i class="fa fa-check"></i> <b>1.2.</b> Swift初见 <i class="fa fa-check"></i> <b>1.2.</b> Swift 初见
</a> </a>
@ -157,7 +157,7 @@
<li class="chapter " data-level="2" data-path="chapter2/the_basics.html"> <li class="chapter " data-level="2" data-path="chapter2/the_basics.html">
<a href="../chapter2/the_basics.html"> <a href="../chapter2/the_basics.html">
<i class="fa fa-check"></i> <b>2.</b> Swift教程 <i class="fa fa-check"></i> <b>2.</b> Swift 教程
</a> </a>
@ -200,13 +200,13 @@
<a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a> <a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a>
<a href="../chapter1/README.html" title="欢迎使用Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a> <a href="../chapter1/README.html" title="欢迎使用 Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a>
<a href="../chapter1/swift.html" title="关于Swift" class="chapter done " data-progress="1.1" style="left: 40%;"></a> <a href="../chapter1/swift.html" title="关于 Swift" class="chapter done " data-progress="1.1" style="left: 40%;"></a>
<a href="../chapter1/a_swift_tour.html" title="Swift初见" class="chapter done " data-progress="1.2" style="left: 60%;"></a> <a href="../chapter1/a_swift_tour.html" title="Swift 初见" class="chapter done " data-progress="1.2" style="left: 60%;"></a>
<a href="../chapter2/the_basics.html" title="Swift教程" class="chapter done new-chapter" data-progress="2" style="left: 80%;"></a> <a href="../chapter2/the_basics.html" title="Swift 教程" class="chapter done new-chapter" data-progress="2" style="left: 80%;"></a>
<a href="../chapter2/article_1.html" title="基础部分" class="chapter done " data-progress="2.1" style="left: 100%;"></a> <a href="../chapter2/article_1.html" title="基础部分" class="chapter done " data-progress="2.1" style="left: 100%;"></a>
@ -215,15 +215,15 @@
<div class="page-inner"> <div class="page-inner">
<section class="normal" id="section-gitbook_10"> <section class="normal" id="section-gitbook_144">
<h1 id="-">基础部分</h1> <h1 id="-">基础部分</h1>
<p>Swift是iOS和OS X应用开发的一门新语言。然而如果你有C或者Objective-C开发经验的话你会发现Swift的很多内容都是你熟悉的。</p> <p>Swift 是 iOS 和 OS X 应用开发的一门新语言。然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的。</p>
<p>Swift的类型是在C和Objective-C的基础上提出的<code>Int</code>是整型;<code>Double</code><code>Float</code>是浮点型;<code>Bool</code>是布尔型;<code>String</code>是字符串。Swift还有两个有用的集合类型<code>Array</code><code>Dictionary</code>,详情参见<code>集合类型(待添加链接)</code></p> <p>Swift 的类型是在 C 和 Objective-C 的基础上提出的,<code>Int</code>是整型;<code>Double</code><code>Float</code>是浮点型;<code>Bool</code>是布尔型;<code>String</code>是字符串。Swift 还有两个有用的集合类型,<code>Array</code><code>Dictionary</code>,详情参见<code>集合类型(待添加链接)</code></p>
<p>就像C语言一样Swift使用变量来进行存储并通过变量名来关联值。在Swift中值不可变的变量有着广泛的应用它们就是常量而且比C语言的常量更强大。在Swift中如果你要处理的值不需要改变那使用常量可以让你的代码更加安全并且更好地表达你的意图。</p> <p>就像 C 语言一样Swift 使用变量来进行存储并通过变量名来关联值。在 Swift 中,值不可变的变量有着广泛的应用,它们就是常量,而且比 C 语言的常量更强大。在 Swift 中,如果你要处理的值不需要改变,那使用常量可以让你的代码更加安全并且更好地表达你的意图。</p>
<p>除了我们熟悉的类型Swift还增加了Objective-C中没有的类型比如元组Tuple。元组可以让你创建或者传递一组数据比如作为函数的返回值时你可以用一个元组可以返回多个值。</p> <p>除了我们熟悉的类型Swift 还增加了 Objective-C 中没有的类型比如元组Tuple。元组可以让你创建或者传递一组数据比如作为函数的返回值时你可以用一个元组可以返回多个值。</p>
<p>Swift还增加了可选Optional类型用于处理值缺失的情况。可选表示“那儿有一个值并且它等于x”或者“那儿没有值”。可选有点像在Objective-C中使用<code>nil</code>但是它可以用在任何类型上不仅仅是类。可选类型比Objective-C中的<code>nil</code>指针更加安全也更具表现力它是Swift许多强大特性的重要组成部分。</p> <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> <p>Swift 是一个类型安全的语言可选就是一个很好的例子。Swift 可以让你清楚地知道值的类型。如果你的代码期望得到一个<code>String</code>,类型安全会阻止你不小心传入一个<code>Int</code>。你可以在开发阶段尽早发现并修正错误。</p>
<h2 id="-">常量和变量</h2> <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> <h3 id="-">声明常量和变量</h3>
@ -251,6 +251,7 @@ var currentLoginAttempt = 0
<p>注意一般来说你很少需要写类型标注。如果你在声明常量或者变量的时候赋了一个初始值Swift可以推断出这个常量或者变量的类型详情参见<code>类型安全和类型推断(待添加链接)</code>。在上面的例子中,没有给<code>welcomeMessage</code>赋初始值,所以添加了一个类型标注。</p> <p>注意一般来说你很少需要写类型标注。如果你在声明常量或者变量的时候赋了一个初始值Swift可以推断出这个常量或者变量的类型详情参见<code>类型安全和类型推断(待添加链接)</code>。在上面的例子中,没有给<code>welcomeMessage</code>赋初始值,所以添加了一个类型标注。</p>
</blockquote> </blockquote>
<h3 id="-">常量和变量的命名</h3> <h3 id="-">常量和变量的命名</h3>
<p>(未完)</p>
</section> </section>
@ -260,7 +261,7 @@ var currentLoginAttempt = 0
</div> </div>
<a href="../chapter2/the_basics.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Swift教程"><i class="fa fa-angle-left"></i></a> <a href="../chapter2/the_basics.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Swift 教程"><i class="fa fa-angle-left"></i></a>
</div> </div>

View File

@ -5,12 +5,12 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Swift教程 | Swift编程语言</title> <title>Swift 教程 | Swift 编程语言</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="robots" content="index, follow"> <meta name="robots" content="index, follow">
<meta name="author" content=""> <meta name="author" content="">
<meta name="description" content="Swift是苹果在WWDC2014上发布的一款全新的编程语言本书译自苹果官方的Swift教程《The Swift Programming Language》。"> <meta name="description" content="Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。">
<meta name="keywords" content="gitbook,github" > <meta name="keywords" content="gitbook,github" >
<meta name="generator" content="www.gitbook.io"> <meta name="generator" content="www.gitbook.io">
@ -21,8 +21,8 @@
<link rel="prev" href="../chapter1/a_swift_tour.html" /> <link rel="prev" href="../chapter1/a_swift_tour.html" />
<meta property="og:title" content="Swift教程 | Swift编程语言"> <meta property="og:title" content="Swift 教程 | Swift 编程语言">
<meta property="og:site_name" content="Swift编程语言"> <meta property="og:site_name" content="Swift 编程语言">
<meta property="og:type" content="book"> <meta property="og:type" content="book">
<meta property="og:locale" content="en_US"> <meta property="og:locale" content="en_US">
@ -46,7 +46,7 @@
<div class="book" data-level="2" data-basepath=".." data-revision="1401879002086"> <div class="book" data-level="2" data-basepath=".." data-revision="1401881908280">
<div class="book-header"> <div class="book-header">
<!-- Actions Left --> <!-- Actions Left -->
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a> <a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
@ -98,7 +98,7 @@
<!-- Title --> <!-- Title -->
<h1> <h1>
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin"></i>
<a href="../" >Swift编程语言</a> <a href="../" >Swift 编程语言</a>
</h1> </h1>
</div> </div>
@ -126,7 +126,7 @@
<li class="chapter " data-level="1" data-path="chapter1/README.html"> <li class="chapter " data-level="1" data-path="chapter1/README.html">
<a href="../chapter1/README.html"> <a href="../chapter1/README.html">
<i class="fa fa-check"></i> <b>1.</b> 欢迎使用Swift <i class="fa fa-check"></i> <b>1.</b> 欢迎使用 Swift
</a> </a>
@ -136,7 +136,7 @@
<li class="chapter " data-level="1.1" data-path="chapter1/swift.html"> <li class="chapter " data-level="1.1" data-path="chapter1/swift.html">
<a href="../chapter1/swift.html"> <a href="../chapter1/swift.html">
<i class="fa fa-check"></i> <b>1.1.</b> 关于Swift <i class="fa fa-check"></i> <b>1.1.</b> 关于 Swift
</a> </a>
@ -145,7 +145,7 @@
<li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html"> <li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html">
<a href="../chapter1/a_swift_tour.html"> <a href="../chapter1/a_swift_tour.html">
<i class="fa fa-check"></i> <b>1.2.</b> Swift初见 <i class="fa fa-check"></i> <b>1.2.</b> Swift 初见
</a> </a>
@ -159,7 +159,7 @@
<li class="chapter " data-level="2" data-path="chapter2/the_basics.html"> <li class="chapter " data-level="2" data-path="chapter2/the_basics.html">
<a href="../chapter2/the_basics.html"> <a href="../chapter2/the_basics.html">
<i class="fa fa-check"></i> <b>2.</b> Swift教程 <i class="fa fa-check"></i> <b>2.</b> Swift 教程
</a> </a>
@ -202,13 +202,13 @@
<a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a> <a href="../index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a>
<a href="../chapter1/README.html" title="欢迎使用Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a> <a href="../chapter1/README.html" title="欢迎使用 Swift" class="chapter done new-chapter" data-progress="1" style="left: 20%;"></a>
<a href="../chapter1/swift.html" title="关于Swift" class="chapter done " data-progress="1.1" style="left: 40%;"></a> <a href="../chapter1/swift.html" title="关于 Swift" class="chapter done " data-progress="1.1" style="left: 40%;"></a>
<a href="../chapter1/a_swift_tour.html" title="Swift初见" class="chapter done " data-progress="1.2" style="left: 60%;"></a> <a href="../chapter1/a_swift_tour.html" title="Swift 初见" class="chapter done " data-progress="1.2" style="left: 60%;"></a>
<a href="../chapter2/the_basics.html" title="Swift教程" class="chapter done new-chapter" data-progress="2" style="left: 80%;"></a> <a href="../chapter2/the_basics.html" title="Swift 教程" class="chapter done new-chapter" data-progress="2" style="left: 80%;"></a>
<a href="../chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a> <a href="../chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a>
@ -217,10 +217,10 @@
<div class="page-inner"> <div class="page-inner">
<section class="normal" id="section-gitbook_11"> <section class="normal" id="section-gitbook_145">
<h1 id="swift-">Swift教程</h1> <h1 id="swift-">Swift 教程</h1>
<p>本章介绍了Swift的各种特性及其使用方法是全书的核心部分。</p> <p>本章介绍了 Swift 的各种特性及其使用方法,是全书的核心部分。</p>
</section> </section>
@ -230,7 +230,7 @@
</div> </div>
<a href="../chapter1/a_swift_tour.html" class="navigation navigation-prev " aria-label="Previous page: Swift初见"><i class="fa fa-angle-left"></i></a> <a href="../chapter1/a_swift_tour.html" class="navigation navigation-prev " aria-label="Previous page: Swift 初见"><i class="fa fa-angle-left"></i></a>
<a href="../chapter2/article_1.html" class="navigation navigation-next " aria-label="Next page: 基础部分"><i class="fa fa-angle-right"></i></a> <a href="../chapter2/article_1.html" class="navigation navigation-next " aria-label="Next page: 基础部分"><i class="fa fa-angle-right"></i></a>

View File

@ -5,12 +5,12 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Introduction | Swift编程语言</title> <title>Introduction | Swift 编程语言</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="robots" content="index, follow"> <meta name="robots" content="index, follow">
<meta name="author" content=""> <meta name="author" content="">
<meta name="description" content="Swift是苹果在WWDC2014上发布的一款全新的编程语言本书译自苹果官方的Swift教程《The Swift Programming Language》。"> <meta name="description" content="Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。">
<meta name="keywords" content="gitbook,github" > <meta name="keywords" content="gitbook,github" >
<meta name="generator" content="www.gitbook.io"> <meta name="generator" content="www.gitbook.io">
@ -19,8 +19,8 @@
<meta property="og:title" content="Introduction | Swift编程语言"> <meta property="og:title" content="Introduction | Swift 编程语言">
<meta property="og:site_name" content="Swift编程语言"> <meta property="og:site_name" content="Swift 编程语言">
<meta property="og:type" content="book"> <meta property="og:type" content="book">
<meta property="og:locale" content="en_US"> <meta property="og:locale" content="en_US">
@ -44,7 +44,7 @@
<div class="book" data-level="0" data-basepath="." data-revision="1401879002086"> <div class="book" data-level="0" data-basepath="." data-revision="1401881908280">
<div class="book-header"> <div class="book-header">
<!-- Actions Left --> <!-- Actions Left -->
<a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a> <a href="#" class="btn pull-left toggle-summary" aria-label="Toggle summary"><i class="fa fa-align-justify"></i></a>
@ -96,7 +96,7 @@
<!-- Title --> <!-- Title -->
<h1> <h1>
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin"></i>
<a href="./" >Swift编程语言</a> <a href="./" >Swift 编程语言</a>
</h1> </h1>
</div> </div>
@ -124,7 +124,7 @@
<li class="chapter " data-level="1" data-path="chapter1/README.html"> <li class="chapter " data-level="1" data-path="chapter1/README.html">
<a href="./chapter1/README.html"> <a href="./chapter1/README.html">
<i class="fa fa-check"></i> <b>1.</b> 欢迎使用Swift <i class="fa fa-check"></i> <b>1.</b> 欢迎使用 Swift
</a> </a>
@ -134,7 +134,7 @@
<li class="chapter " data-level="1.1" data-path="chapter1/swift.html"> <li class="chapter " data-level="1.1" data-path="chapter1/swift.html">
<a href="./chapter1/swift.html"> <a href="./chapter1/swift.html">
<i class="fa fa-check"></i> <b>1.1.</b> 关于Swift <i class="fa fa-check"></i> <b>1.1.</b> 关于 Swift
</a> </a>
@ -143,7 +143,7 @@
<li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html"> <li class="chapter " data-level="1.2" data-path="chapter1/a_swift_tour.html">
<a href="./chapter1/a_swift_tour.html"> <a href="./chapter1/a_swift_tour.html">
<i class="fa fa-check"></i> <b>1.2.</b> Swift初见 <i class="fa fa-check"></i> <b>1.2.</b> Swift 初见
</a> </a>
@ -157,7 +157,7 @@
<li class="chapter " data-level="2" data-path="chapter2/the_basics.html"> <li class="chapter " data-level="2" data-path="chapter2/the_basics.html">
<a href="./chapter2/the_basics.html"> <a href="./chapter2/the_basics.html">
<i class="fa fa-check"></i> <b>2.</b> Swift教程 <i class="fa fa-check"></i> <b>2.</b> Swift 教程
</a> </a>
@ -200,13 +200,13 @@
<a href="./index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a> <a href="./index.html" title="Introduction" class="chapter done new-chapter" data-progress="0" style="left: 0%;"></a>
<a href="./chapter1/README.html" title="欢迎使用Swift" class="chapter new-chapter" data-progress="1" style="left: 20%;"></a> <a href="./chapter1/README.html" title="欢迎使用 Swift" class="chapter new-chapter" data-progress="1" style="left: 20%;"></a>
<a href="./chapter1/swift.html" title="关于Swift" class="chapter " data-progress="1.1" style="left: 40%;"></a> <a href="./chapter1/swift.html" title="关于 Swift" class="chapter " data-progress="1.1" style="left: 40%;"></a>
<a href="./chapter1/a_swift_tour.html" title="Swift初见" class="chapter " data-progress="1.2" style="left: 60%;"></a> <a href="./chapter1/a_swift_tour.html" title="Swift 初见" class="chapter " data-progress="1.2" style="left: 60%;"></a>
<a href="./chapter2/the_basics.html" title="Swift教程" class="chapter new-chapter" data-progress="2" style="left: 80%;"></a> <a href="./chapter2/the_basics.html" title="Swift 教程" class="chapter new-chapter" data-progress="2" style="left: 80%;"></a>
<a href="./chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a> <a href="./chapter2/article_1.html" title="基础部分" class="chapter " data-progress="2.1" style="left: 100%;"></a>
@ -215,10 +215,10 @@
<div class="page-inner"> <div class="page-inner">
<section class="normal" id="section-gitbook_6"> <section class="normal" id="section-gitbook_140">
<h1 id="swift-">Swift编程语言</h1> <h1 id="swift-">Swift 编程语言</h1>
<p>Swift是苹果在WWDC2014上发布的一款全新的编程语言本书译自苹果官方的Swift教程《The Swift Programming Language》。</p> <p>Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。</p>
<p>感谢您的阅读。</p> <p>感谢您的阅读。</p>
@ -230,7 +230,7 @@
<a href="./chapter1/README.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 欢迎使用Swift"><i class="fa fa-angle-right"></i></a> <a href="./chapter1/README.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 欢迎使用 Swift"><i class="fa fa-angle-right"></i></a>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# Revision 1401879002087 # Revision 1401881908282
CACHE: CACHE:
index.html index.html

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
# Swift编程语言 # Swift 编程语言
Swift是苹果在WWDC2014上发布的一款全新的编程语言本书译自苹果官方的Swift教程《The Swift Programming Language》。 Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。
感谢您的阅读。 感谢您的阅读。

View File

@ -1,8 +1,8 @@
# Summary # Summary
* [欢迎使用Swift](chapter1/README.md) * [欢迎使用 Swift](chapter1/README.md)
* [关于Swift](chapter1/swift.md) * [关于 Swift](chapter1/swift.md)
* [Swift初见](chapter1/a_swift_tour.md) * [Swift 初见](chapter1/a_swift_tour.md)
* [Swift教程](chapter2/the_basics.md) * [Swift 教程](chapter2/the_basics.md)
* [基础部分](chapter2/article_1.md) * [基础部分](chapter2/article_1.md)

View File

@ -1,4 +1,4 @@
# 欢迎使用Swift # 欢迎使用 Swift
在本章中您将了解Swift的特性和开发历史并对Swift有一个初步的了解。 在本章中您将了解 Swift 的特性和开发历史,并对 Swift 有一个初步的了解。

View File

@ -1,14 +1,14 @@
# Swift初见 # Swift 初见
通常来说编程语言教程中的第一个程序应该在屏幕上打印“Hello, world”。在Swift中可以用一行代码实现 通常来说编程语言教程中的第一个程序应该在屏幕上打印“Hello, world”。在 Swift 中,可以用一行代码实现:
println("hello, world") println("hello, world")
如果你写过C或者Objective-C代码那你应该很熟悉这种形式——在Swift中这行代码就是一个完整的程序。你不需要为了输入输出或者字符串处理导入一个单独的库。全局作用域中的代码会被自动当做程序的入口点所以你也不需要`main`函数。你同样不需要在每个语句结尾写上分号。 如果你写过 C 或者 Objective-C 代码,那你应该很熟悉这种形式——在 Swift 中,这行代码就是一个完整的程序。你不需要为了输入输出或者字符串处理导入一个单独的库。全局作用域中的代码会被自动当做程序的入口点,所以你也不需要`main`函数。你同样不需要在每个语句结尾写上分号。
这个教程会通过一系列编程例子来让你对Swift有初步了解如果你有什么不理解的地方也不用担心——任何本章介绍的内容都会在后面的章节中详细讲解。 这个教程会通过一系列编程例子来让你对 Swift 有初步了解,如果你有什么不理解的地方也不用担心——任何本章介绍的内容都会在后面的章节中详细讲解。
> 注意为了获得最好的体验在Xcode当中使用代码预览功能。代码预览功能可以让你编辑代码并实时看到运行结果。 > 注意:为了获得最好的体验,在 Xcode 当中使用代码预览功能。代码预览功能可以让你编辑代码并实时看到运行结果。
## 简单值 ## 简单值
@ -316,7 +316,7 @@
> 练习:创建`NamedShape`的另一个子类`Circle`,构造器接收两个参数,一个是半径一个是名称,实现`area`和`describe`方法。 > 练习:创建`NamedShape`的另一个子类`Circle`,构造器接收两个参数,一个是半径一个是名称,实现`area`和`describe`方法。
属性可以有gettersetter。 属性可以有 gettersetter
class EquilateralTriangle: NamedShape { class EquilateralTriangle: NamedShape {
var sideLength: Double = 0.0 var sideLength: Double = 0.0
@ -345,7 +345,7 @@
triangle.perimeter = 9.9 triangle.perimeter = 9.9
triangle.sideLength triangle.sideLength
`perimeter`的setter中新值的名字是`newValue`。你可以在`set`之后显示的设置一个名字。 `perimeter` setter 中,新值的名字是`newValue`。你可以在`set`之后显示的设置一个名字。
注意`EquilateralTriangle`类的构造器执行了三步: 注意`EquilateralTriangle`类的构造器执行了三步:

View File

@ -1,13 +1,13 @@
# 关于Swift # 关于 Swift
Swift是一种新的编程语言用于编写iOSOS X应用程序。Swift结合了C和Objective-C的优点并且不受C的兼容性的限制。Swift使用安全的编程模式并添加了很多新特性这将使编程更简单扩展性更强也更有趣。除此之外Swift还支持人见人爱的CocoaCocoa Touch框架。拥有了这些特性Swift将重新定义软件开发。 Swift 是一种新的编程语言,用于编写 iOSOS X 应用程序。Swift 结合了 C 和 Objective-C 的优点并且不受C的兼容性的限制。Swift 使用安全的编程模式并添加了很多新特性这将使编程更简单扩展性更强也更有趣。除此之外Swift 还支持人见人爱的 CocoaCocoa Touch 框架。拥有了这些特性Swift将重新定义软件开发。
Swift的开发从很久之前就开始了。为了给Swift打好基础苹果公司改进了编译器调试器和框架结构。我们使用自动引用计数Automatic Reference Counting, ARC来简化内存管理。我们在FoundationCocoa的基础上构建框架栈并将其标准化。Objective-C本身支持块、集合语法和模块所以框架可以轻松支持现代编程语言技术。得益于这些基础工作我们现在可以发布一个新语言用于未来的苹果软件的开发。 Swift 的开发从很久之前就开始了。为了给 Swift 打好基础苹果公司改进了编译器调试器和框架结构。我们使用自动引用计数Automatic Reference Counting, ARC来简化内存管理。我们在 FoundationCocoa的基础上构建框架栈并将其标准化。Objective-C 本身支持块、集合语法和模块,所以框架可以轻松支持现代编程语言技术。得益于这些基础工作,我们现在可以发布一个新语言,用于未来的苹果软件的开发。
Objective-C开发者对于Swift并不会感到陌生。它采用了Objective-C的命名参数以及动态对象模型可以无缝对接到现有的Cocoa框架并且可以兼容Objective-C代码。在此基础之上Swift还有许多新特性并且支持过程式编程和面向对象编程。 Objective-C 开发者对于 Swift 并不会感到陌生。它采用了 Objective-C 的命名参数以及动态对象模型,可以无缝对接到现有的 Cocoa 框架,并且可以兼容 Objective-C 代码。在此基础之上Swift 还有许多新特性并且支持过程式编程和面向对象编程。
Swift对于初学者来说也很友好。它是第一个既满足工业标准又像脚本语言一样充满表现力和趣味的编程语言。它支持代码预览这个革命性的特性可以允许程序员在不编译和运行应用程序的前提下运行Swift代码并实时查看结果。 Swift 对于初学者来说也很友好。它是第一个既满足工业标准又像脚本语言一样充满表现力和趣味的编程语言。它支持代码预览,这个革命性的特性可以允许程序员在不编译和运行应用程序的前提下运行 Swift 代码并实时查看结果。
Swift将现代编程语言的精华和苹果工程师文化的智慧结合了起来。编译器对性能进行了优化编程语言对开发进行了优化两者互不干扰鱼与熊掌兼得。Swift即可以用于开发“hello, world”这样的小程序也可以用于开发一个完整的操作系统。所有的这些特性让Swift对于开发者和苹果来说都是一项值得的投资。 Swift 将现代编程语言的精华和苹果工程师文化的智慧结合了起来。编译器对性能进行了优化编程语言对开发进行了优化两者互不干扰鱼与熊掌兼得。Swift 即可以用于开发“hello, world”这样的小程序也可以用于开发一个完整的操作系统。所有的这些特性让 Swift 对于开发者和苹果来说都是一项值得的投资。
用Swift编写iOSOS X应用将是一场美妙的体验Swift之后也会不断开发新特性和兼容性。我们对Swift充满信心你还在等什么 Swift 编写 iOSOS X 应用将是一场美妙的体验Swift 之后也会不断开发新特性和兼容性。我们对 Swift 充满信心,你还在等什么!

View File

@ -1,16 +1,16 @@
# 基础部分 # 基础部分
Swift是iOS和OS X应用开发的一门新语言。然而如果你有C或者Objective-C开发经验的话你会发现Swift的很多内容都是你熟悉的。 Swift 是 iOS 和 OS X 应用开发的一门新语言。然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的。
Swift的类型是在C和Objective-C的基础上提出的`Int`是整型;`Double``Float`是浮点型;`Bool`是布尔型;`String`是字符串。Swift还有两个有用的集合类型`Array``Dictionary`,详情参见`集合类型(待添加链接)` Swift 的类型是在 C 和 Objective-C 的基础上提出的,`Int`是整型;`Double``Float`是浮点型;`Bool`是布尔型;`String`是字符串。Swift 还有两个有用的集合类型,`Array``Dictionary`,详情参见`集合类型(待添加链接)`
就像C语言一样Swift使用变量来进行存储并通过变量名来关联值。在Swift中值不可变的变量有着广泛的应用它们就是常量而且比C语言的常量更强大。在Swift中如果你要处理的值不需要改变那使用常量可以让你的代码更加安全并且更好地表达你的意图。 就像 C 语言一样Swift 使用变量来进行存储并通过变量名来关联值。在 Swift 中,值不可变的变量有着广泛的应用,它们就是常量,而且比 C 语言的常量更强大。在 Swift 中,如果你要处理的值不需要改变,那使用常量可以让你的代码更加安全并且更好地表达你的意图。
除了我们熟悉的类型Swift还增加了Objective-C中没有的类型比如元组Tuple。元组可以让你创建或者传递一组数据比如作为函数的返回值时你可以用一个元组可以返回多个值。 除了我们熟悉的类型Swift 还增加了 Objective-C 中没有的类型比如元组Tuple。元组可以让你创建或者传递一组数据比如作为函数的返回值时你可以用一个元组可以返回多个值。
Swift还增加了可选Optional类型用于处理值缺失的情况。可选表示“那儿有一个值并且它等于x”或者“那儿没有值”。可选有点像在Objective-C中使用`nil`但是它可以用在任何类型上不仅仅是类。可选类型比Objective-C中的`nil`指针更加安全也更具表现力它是Swift许多强大特性的重要组成部分。 Swift 还增加了可选Optional类型用于处理值缺失的情况。可选表示“那儿有一个值并且它等于 x ”或者“那儿没有值”。可选有点像在 Objective-C 中使用`nil`,但是它可以用在任何类型上,不仅仅是类。可选类型比 Objective-C 中的`nil`指针更加安全也更具表现力,它是 Swift 许多强大特性的重要组成部分。
Swift是一个类型安全的语言可选就是一个很好的例子。Swift可以让你清楚地知道值的类型。如果你的代码期望得到一个`String`,类型安全会阻止你不小心传入一个`Int`。你可以在开发阶段尽早发现并修正错误。 Swift 是一个类型安全的语言可选就是一个很好的例子。Swift 可以让你清楚地知道值的类型。如果你的代码期望得到一个`String`,类型安全会阻止你不小心传入一个`Int`。你可以在开发阶段尽早发现并修正错误。
## 常量和变量 ## 常量和变量
@ -58,3 +58,4 @@ Swift是一个类型安全的语言可选就是一个很好的例子。Swift
### 常量和变量的命名 ### 常量和变量的命名
(未完)

View File

@ -1,3 +1,3 @@
# Swift教程 # Swift 教程
本章介绍了Swift的各种特性及其使用方法是全书的核心部分。 本章介绍了 Swift 的各种特性及其使用方法,是全书的核心部分。