diff --git a/chapter1/01_swift.html b/chapter1/01_swift.html index 268132a4..aef8a566 100644 --- a/chapter1/01_swift.html +++ b/chapter1/01_swift.html @@ -46,7 +46,7 @@ -
Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用程序。Swift 结合了 C 和 Objective-C 的优点并且不受C的兼容性的限制。Swift 使用安全的编程模式并添加了很多新特性,这将使编程更简单,扩展性更强,也更有趣。除此之外,Swift 还支持人见人爱的 Cocoa 和 Cocoa Touch 框架。拥有了这些特性,Swift将重新定义软件开发。
diff --git a/chapter1/02_a_swift_tour.html b/chapter1/02_a_swift_tour.html index 20a869a2..4c9cecb5 100644 --- a/chapter1/02_a_swift_tour.html +++ b/chapter1/02_a_swift_tour.html @@ -46,7 +46,7 @@ -本页内容包括:
diff --git a/chapter1/chapter1.html b/chapter1/chapter1.html index f7b14476..32e96352 100644 --- a/chapter1/chapter1.html +++ b/chapter1/chapter1.html @@ -46,7 +46,7 @@ -在本章中您将了解 Swift 的特性和开发历史,并对 Swift 有一个初步的了解。
diff --git a/chapter2/01_The_Basics.html b/chapter2/01_The_Basics.html index 7ac40f25..7f174f4b 100644 --- a/chapter2/01_The_Basics.html +++ b/chapter2/01_The_Basics.html @@ -46,7 +46,7 @@ -Swift 是 iOS 和 OS X 应用开发的一门新语言。然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的。
@@ -780,7 +780,7 @@ let pi = Double(three) + pointOneFourOneFiveNine浮点数转换为整数也一样,整数类型可以用Double或者Float类型来初始化:
let integerPi = Int(pi)
// integerPi 等于 3,所以被推测为 Int 类型
-当用这种方式来初始化一个新的整数值时,浮点值会被截断。也就是说4.75会变成4,-3.9会变成3。
当用这种方式来初始化一个新的整数值时,浮点值会被截断。也就是说4.75会变成4,-3.9会变成-3。
diff --git a/chapter2/02_Basic_Operators.html b/chapter2/02_Basic_Operators.html index 76786aae..45683900 100644 --- a/chapter2/02_Basic_Operators.html +++ b/chapter2/02_Basic_Operators.html @@ -46,7 +46,7 @@ -注意:结合数字类常量和变量不同于结合数字类原始值。原始值
3可以直接和原始值0.14159相加,因为数字原始值本身没有明确的类型。它们的类型只在编译器需要求值的时候被推测。
运算符是检查, 改变, 合并值的特殊符号或短语. 例如, 加号 + 把计算两个数的和(如 let i = 1 + 2). 复杂些的运行算包括逻辑与&&(如 if enteredDoorCode && passedRetinaScan), 还有自增运算符 ++i 这样让自身加一的便捷运算.
本页包含内容:
diff --git a/chapter2/04_Collection_Types.html b/chapter2/04_Collection_Types.html index 36daec50..8263c0ed 100644 --- a/chapter2/04_Collection_Types.html +++ b/chapter2/04_Collection_Types.html @@ -46,7 +46,7 @@ -本页包含内容:
diff --git a/chapter2/07_Closures.html b/chapter2/07_Closures.html index 1a752fdf..2669ed1b 100644 --- a/chapter2/07_Closures.html +++ b/chapter2/07_Closures.html @@ -46,7 +46,7 @@ -本页内容包含:
diff --git a/chapter2/08_Enumerations.html b/chapter2/08_Enumerations.html index cf083efd..5c620862 100644 --- a/chapter2/08_Enumerations.html +++ b/chapter2/08_Enumerations.html @@ -46,7 +46,7 @@ -本页包含内容:
diff --git a/chapter2/10_Properties.html b/chapter2/10_Properties.html index bdaec3fe..231fd742 100644 --- a/chapter2/10_Properties.html +++ b/chapter2/10_Properties.html @@ -46,7 +46,7 @@ -一个类可以继承另一个类的方法,属性和其它特性。当一个类继承其它类,继承类叫子类,被继承类叫超类(或父类)。在Swift中,继承是区分「类」与其它类型的一个基本特征。
diff --git a/chapter2/14_Initialization.html b/chapter2/14_Initialization.html index cc235e47..6cb8ddec 100644 --- a/chapter2/14_Initialization.html +++ b/chapter2/14_Initialization.html @@ -46,7 +46,7 @@ -在一个类的实例被释放之前,析构函数被立即调用。用关键字deinit来标示析构函数,类似于初始化函数用init来标示。析构函数只适用于类类型。
diff --git a/chapter2/16_Automatic_Reference_Counting.html b/chapter2/16_Automatic_Reference_Counting.html index 0d4bf400..786c6308 100644 --- a/chapter2/16_Automatic_Reference_Counting.html +++ b/chapter2/16_Automatic_Reference_Counting.html @@ -46,7 +46,7 @@ -本页包含内容:
diff --git a/chapter2/17_Optional_Chaining.html b/chapter2/17_Optional_Chaining.html index 1d57fde1..75a1eeeb 100644 --- a/chapter2/17_Optional_Chaining.html +++ b/chapter2/17_Optional_Chaining.html @@ -46,7 +46,7 @@ -可选链(Optional Chaining)是一种可以请求和调用属性、方法及子脚本的过程,它的自判断性体现于请求或调用的目标当前可能为空(nil)。如果自判断的目标有值,那么调用就会成功;相反,如果选择的目标为空(nil),则这种调用将返回空(nil)。多次请求或调用可以被链接在一起形成一个链,如果任何一个节点为空(nil)将导致整个链失效。
(ps:为了方便各位检验所以保留了英文,可删。) diff --git a/chapter2/19_Nested_Types.html b/chapter2/19_Nested_Types.html index a5f6a3d3..8281830f 100644 --- a/chapter2/19_Nested_Types.html +++ b/chapter2/19_Nested_Types.html @@ -46,7 +46,7 @@ -
本页包含内容:
diff --git a/chapter2/20_Extensions.html b/chapter2/20_Extensions.html index 0af8feda..f35f50af 100644 --- a/chapter2/20_Extensions.html +++ b/chapter2/20_Extensions.html @@ -46,7 +46,7 @@ -本章介绍了 Swift 的各种特性及其使用方法,是全书的核心部分。
diff --git a/chapter3/01_About_the_Language_Reference.html b/chapter3/01_About_the_Language_Reference.html index 19ba16a5..1fe72391 100644 --- a/chapter3/01_About_the_Language_Reference.html +++ b/chapter3/01_About_the_Language_Reference.html @@ -46,7 +46,7 @@ -本书的这一节描述了Swift编程语言的形式语法。这里描述的语法是为了帮助您更详细的了解该语言,而不是让您直接实现一个解析器或编译器。
diff --git a/chapter3/02_Lexical_Structure.html b/chapter3/02_Lexical_Structure.html index 5cde72b1..a115a2f0 100644 --- a/chapter3/02_Lexical_Structure.html +++ b/chapter3/02_Lexical_Structure.html @@ -46,7 +46,7 @@ -Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。
diff --git a/manifest.appcache b/manifest.appcache index 828dbc25..c7b24ff3 100644 --- a/manifest.appcache +++ b/manifest.appcache @@ -1,12 +1,12 @@ CACHE MANIFEST -# Revision 1402225140869 +# Revision 1402235469938 CACHE: index.html chapter1/01_swift.html +chapter1/02_a_swift_tour.html chapter1/chapter1.html chapter2/13_Inheritance.html -chapter1/02_a_swift_tour.html chapter2/01_The_Basics.html chapter2/03_Strings_and_Characters.html chapter2/04_Collection_Types.html @@ -77,8 +77,8 @@ gitbook/jsrepl/sandbox.html gitbook/jsrepl/sandbox.js gitbook/print.css gitbook/style.css -gitbook/plugins/gitbook-plugin-mathjax/plugin.js gitbook/plugins/gitbook-plugin-mixpanel/plugin.js +gitbook/plugins/gitbook-plugin-mathjax/plugin.js NETWORK: * \ No newline at end of file diff --git a/search_index.json b/search_index.json index c1773c3c..1e9f1b0d 100644 --- a/search_index.json +++ b/search_index.json @@ -1 +1 @@ -{"version":"0.5.2","fields":[{"name":"title","boost":10},{"name":"body","boost":1}],"ref":"url","documentStore":{"store":{"index.html#gitbook_4":["2014","issu","languag","program","pull","qq群:364279588","request","swift","undefinedundefin","wwdc"],"chapter1/01_swift.html#gitbook_5":["arc","automat","c","cocoa","cocoa的基础上构建框架栈并将其标准化。objective-c","count","c的兼容性的限制。swift","foundat","hello","io","objective-c","os","refer","swift","touch","undefinedundefin","world","x"],"chapter1/chapter1.html#gitbook_6":["swift","undefinedundefin"],"chapter2/13_Inheritance.html#gitbook_7":["0","0.0","0和maxpasseng","1","10.0","2","35.0","4","40.0","5","60.0","automat","automatic.descript","automatic.spe","automaticcar","automaticcar的speed属性,属性的didset观察器就会自动地设置gear属性,为新的速度选择一个合适的挡位。具体来说就是,属性观察器将新的速度值除以10,然后向下取得最接近的整数值,最后加1来得到档位gear的值。例如,速度为10.0时,挡位为1;速度为35.0时,挡位为4","automaticcar,它是car的子类。automaticcar表示自动挡汽车,它可以根据当前的速度自动选择合适的挡位。automaticcar也提供了定制的descript","bicycl","bicycle.descript","bicycle。这个新类是在vehicle类的基础上创建起来。因此你需要将vehicle类放在bicycl","bicycle不仅可以继承vehicle的属性,还可以继承它的方法。如果你创建了一个bicycle类的实例,你就可以调用它继承来的descript","bicycle是vehicle的子类,vehicle是bicycle的超类。新的bicycle类自动获得vehicle类的特性,比如maxpassengers和numberofwheels属性。你可以在子类中定制这些特性,或添加新的特性来更好地描述bicycl","bicycle的一个子类:双人自行车(tandem)。tandem从bicycle继承了两个属性,而这两个属性是bicycle从vehicle继承而来的。tandem并不修改轮子的数量,因为它仍是一辆自行车,有2个轮子。但它需要修改maxpasseng","bicycle类定义了一个初始化器来设置它定制的特性(自行车只有2个轮子)。bicycle的初始化器调用了它父类vehicle的初始化器super.init(),以此确保在bicycle类试图修改那些继承来的属性前,vehicl","bicycle,它继承了vehicl","car","car.descript","car中的description方法并非完全自定义,而是通过super.description使用了超类vehicle中的descript","car声明了一个新的存储型属性speed,它是double类型的,默认值是0.0,表示“时速是0英里”。'car'有自己的初始化器,它将乘客的最大数量设为5,轮子数量设为4","car的新实例,并打印descript","car重写了继承来的description方法,它的声明与vehicle中的description方法一致,声明前面加上了overrid","class","class前添加@final特性(@fin","class)来将整个类标记为fin","definit","descript","didset","doubl","final","final方法,属性或下标,在编译时会报错。在扩展中,你添加到类里的方法,属性或下标也可以在扩展的定义里标记为fin","final来防止它们被重写,只需要在声明关键字前加上@final特性即可。(例如:@fin","func","gear","getters和sett","getter和sett","getter(或sett","goe","here","init","initi","instanc","int","int(spe","limitedcar","limitedcar.descript","limitedcar.spe","maxpasseng","method),实例属性(inst","method),类方法(class","min(newvalu","mph","numberofwheel","objective-c,在swift","observ","observer),这样一来,当属性值改变时,类就会被通知到。可以为任何属性添加属性观察器,无论它原本被定义为存储型属性(stor","overrid","override关键字。这么做,你就表明了你是想提供一个重写版本,而非错误地提供了一个相同的定义。意外的重写行为可能会导致不可预知的错误,任何缺少overrid","override关键字会提醒swift","passeng","perform","println(\"automaticcar","println(\"bicycl","println(\"car","println(\"speedlimitedcar","println(\"tandem","properti","property)还是计算型属性(comput","property),或下标(subscript)提供自己定制的实现(implementation)。我们把这种行为叫重写(overrid","return","set","setter,那么你也一定要提供getter。如果你不想在重写版本中的getter里修改继承来的属性值,你可以直接返回super.someproperty来返回继承来的值。正如下面的speedlimitedcar","someclass","somemethod的重写实现中,可以通过super.somemethod()来调用超类版本的somemethod","someproperty的getter或setter的重写实现中,可以通过super.someproperty来访问超类版本的someproperti","somesuperclass","somevehicl","speed","speedlimitedcar","speedlimitedcar实例的speed属性时,属性setter的实现会去检查新值与限制值40mph的大小,它会将超类的speed设置为newvalue和40.0中较小的那个。这两个值哪个较小由min函数决定,它是swift标准库中的一个全局函数。min","speedlimitedcar实例的speed属性设置为一个大于40mph的数,然后打印description函数的输出,你会发现速度被限制在40mph","speedlimitedcar,它是car的子类。类speedlimitedcar表示安装了限速装置的车,它的最高速度只能达到40mph。你可以通过重写继承来的spe","string","subclass","subclassing(子类化?待定)重写(overriding)访问超类的方法,属性及下标重写方法重写属性重写属性的getters和setters重写属性观察器(properti","subscript","super","super.descript","super.init","super.spe","super[someindex","swift","swift中,类可以调用和访问超类的方法,属性和下标,并且可以重写(override)这些方法,属性和下标来优化或修改它们的行为。swift","tandem","tandem.descript","tandem类也继承了descript","travel","undefinedundefin","up","var","vehicl","vehicle的一个新的子类,叫car,它重写了从vehicle类继承来的'description'","vehicle的基类。这个基类声明了两个对所有车辆都通用的属性(numberofwheels和maxpassengers)。这些属性在description方法中使用,这个方法返回一个str","vehicle类中maxpassengers的默认值对自行车来说已经是正确的,因此在bicycle的初始化器中并没有改变它。而numberofwheels原来的值对自行车来说是不正确的,因此在初始化器中将它更改为2","vehicle类定义了初始化器(initi","vehicle类的初始化器为任意的一辆车设置一些初始化属性值(numberofwheel","wheel","willset或didset实现是不恰当。此外还要注意,你不可以同时提供重写的setter和重写的属性观察器。如果你想观察属性值的变化,并且你已经为那个属性提供了定制的setter,那么你在sett"],"chapter1/02_a_swift_tour.html#gitbook_8":["0","0..3","0..time","0.0","1","10","100","103","11","12","13","16","19","2","2.5","20","25","3","3.0","3.1","3.59","3.69","3.79","4","42","43","5","5.2","50","597","69105","7","7.simpledescript","70","70.0","75","8","87","8:09","9","9.9","94","a.adjust","a.simpledescript","ac","ace.toraw","acerawvalu","add","addon","addone(numb","adescript","adjust","amount","anoth","anotherproperti","ant","anycommonel","anycommonelements([1","appl","applese","applesummari","area","b","b.adjust","b.simpledescript","bdescript","blue","bool","bottl","c","captain","card","card(rank","card添加一个方法,创建一副完整的扑克牌并把每张牌的rank和suit","case","catfish","celeri","chees","class","club","condit","condition(item","convertedrank","convertedrank.simpledescript","count","counter","counter.incrementby(2","cucumb","dai","default","deinit","diamond","dictionary