apply the change
This commit is contained in:
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="1" data-basepath=".." data-revision="1401881908280">
|
||||
<div class="book" data-level="1" data-basepath=".." data-revision="1401890107706">
|
||||
<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>
|
||||
@ -218,7 +218,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_141">
|
||||
<section class="normal" id="section-gitbook_6">
|
||||
|
||||
<h1 id="-swift">欢迎使用 Swift</h1>
|
||||
<p>在本章中您将了解 Swift 的特性和开发历史,并对 Swift 有一个初步的了解。</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="1.2" data-basepath=".." data-revision="1401881908280">
|
||||
<div class="book" data-level="1.2" data-basepath=".." data-revision="1401890107706">
|
||||
<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>
|
||||
@ -218,7 +218,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_142">
|
||||
<section class="normal" id="section-gitbook_7">
|
||||
|
||||
<h1 id="swift-">Swift 初见</h1>
|
||||
<p>通常来说,编程语言教程中的第一个程序应该在屏幕上打印“Hello, world”。在 Swift 中,可以用一行代码实现:</p>
|
||||
@ -282,7 +282,7 @@ for score in individualScores {
|
||||
}
|
||||
}
|
||||
teamScore
|
||||
</code></pre><p>在<code>if</code>语句中,条件必须是一个布尔表达式——像<code>if score { ... }</code>这样的代码是错误的。</p>
|
||||
</code></pre><p>在<code>if</code>语句中,条件必须是一个布尔表达式——这意味着像<code>if score { ... }</code>这样的代码将报错,而不会隐形地与 0 做对比。</p>
|
||||
<p>你可以一起使用<code>if</code>和<code>let</code>来处理值缺失的情况。有些变量的值是可选的。一个可选的值可能是一个具体的值或者是<code>nil</code>,表示值缺失。在类型后面加一个问号来标记这个变量的值是可选的。</p>
|
||||
<pre><code>var optionalString: String? = "Hello"
|
||||
optionalString == nil
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="1.1" data-basepath=".." data-revision="1401881908280">
|
||||
<div class="book" data-level="1.1" data-basepath=".." data-revision="1401890107706">
|
||||
<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>
|
||||
@ -218,7 +218,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_143">
|
||||
<section class="normal" id="section-gitbook_8">
|
||||
|
||||
<h1 id="-swift">关于 Swift</h1>
|
||||
<p>Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用程序。Swift 结合了 C 和 Objective-C 的优点并且不受C的兼容性的限制。Swift 使用安全的编程模式并添加了很多新特性,这将使编程更简单,扩展性更强,也更有趣。除此之外,Swift 还支持人见人爱的 Cocoa 和 Cocoa Touch 框架。拥有了这些特性,Swift将重新定义软件开发。</p>
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2.1" data-basepath=".." data-revision="1401881908280">
|
||||
<div class="book" data-level="2.1" data-basepath=".." data-revision="1401890107706">
|
||||
<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>
|
||||
@ -216,14 +216,14 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_144">
|
||||
<section class="normal" id="section-gitbook_9">
|
||||
|
||||
<h1 id="-">基础部分</h1>
|
||||
<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>就像 C 语言一样,Swift 使用变量来进行存储并通过变量名来关联值。在 Swift 中,值不可变的变量有着广泛的应用,它们就是常量,而且比 C 语言的常量更强大。在 Swift 中,如果你要处理的值不需要改变,那使用常量可以让你的代码更加安全并且更好地表达你的意图。</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>
|
||||
<h2 id="-">常量和变量</h2>
|
||||
<p>常量和变量把一个名字(比如<code>maximumNumberOfLoginAttempts</code>或者<code>welcomeMessage</code>)和一个指定类型的值(比如数字<code>10</code>或者字符串<code>Hello</code>)联系起来。常量的值一旦设定就不能改变,而变量的值可以随意更改。</p>
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="2" data-basepath=".." data-revision="1401881908280">
|
||||
<div class="book" data-level="2" data-basepath=".." data-revision="1401890107706">
|
||||
<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>
|
||||
@ -218,7 +218,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_145">
|
||||
<section class="normal" id="section-gitbook_10">
|
||||
|
||||
<h1 id="swift-">Swift 教程</h1>
|
||||
<p>本章介绍了 Swift 的各种特性及其使用方法,是全书的核心部分。</p>
|
||||
|
||||
File diff suppressed because one or more lines are too long
10
index.html
10
index.html
@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
|
||||
<div class="book" data-level="0" data-basepath="." data-revision="1401881908280">
|
||||
<div class="book" data-level="0" data-basepath="." data-revision="1401890107706">
|
||||
<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>
|
||||
@ -81,7 +81,6 @@
|
||||
</span>
|
||||
|
||||
<!-- Actions Right -->
|
||||
|
||||
|
||||
<a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Share on Google Plus"><i class="fa fa-google-plus"></i></a>
|
||||
|
||||
@ -187,8 +186,7 @@
|
||||
<a href="http://www.gitbook.io/" target="blank" class="gitbook-link">Generated using GitBook</a>
|
||||
</li>
|
||||
<li style="margin-left:15%;"> <iframe src="http://ghbtns.com/github-btn.html?user=numbbbbb&repo=the-swift-programming-language-in-chinese&type=watch&count=true&size=large"
|
||||
allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe></li>
|
||||
|
||||
allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -218,7 +216,7 @@
|
||||
|
||||
<div class="page-inner">
|
||||
|
||||
<section class="normal" id="section-gitbook_140">
|
||||
<section class="normal" id="section-gitbook_5">
|
||||
|
||||
<h1 id="swift-">Swift 编程语言</h1>
|
||||
<p>Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。</p>
|
||||
@ -269,3 +267,5 @@ require(["gitbook"], function(gitbook) {
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
</html>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
CACHE MANIFEST
|
||||
# Revision 1401881908282
|
||||
# Revision 1401890107708
|
||||
|
||||
CACHE:
|
||||
index.html
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user