diff --git a/source/chapter2/09_Classes_and_Structures.md b/source/chapter2/09_Classes_and_Structures.md index dc51c7f9..6f3c108f 100755 --- a/source/chapter2/09_Classes_and_Structures.md +++ b/source/chapter2/09_Classes_and_Structures.md @@ -113,7 +113,7 @@ println("The width of someVideoMode is \(someVideoMode.resolution.width)") 你也可以使用点语法为属性变量赋值: ```swift -someVideoMode.resolution.width = 12880 +someVideoMode.resolution.width = 1280 println("The width of someVideoMode is now \(someVideoMode.resolution.width)") // 输出 "The width of someVideoMode is now 1280" ``` diff --git a/source/chapter2/10_Properties.md b/source/chapter2/10_Properties.md index 71c59d0e..26fd4937 100755 --- a/source/chapter2/10_Properties.md +++ b/source/chapter2/10_Properties.md @@ -109,7 +109,7 @@ println(manager.importer.fileName) ### 存储属性和实例变量 -如果您有过 Objective-C 经验,应该知道Objective-C为类实例存储值和引提供两种方用。对于属性来说,也可以使用实例变量作为属性值的后端存储。 +如果您有过 Objective-C 经验,应该知道Objective-C为类实例存储值和引提供两种方法。对于属性来说,也可以使用实例变量作为属性值的后端存储。 Swift 编程语言中把这些理论统一用属性来实现。Swift 中的属性没有对应的实例变量,属性的后端存储也无法直接访问。这就避免了不同场景下访问方式的困扰,同时也将属性的定义简化成一个语句。 一个类型中属性的全部信息——包括命名、类型和内存管理特征——都在唯一一个地方(类型定义中)定义。