update to 2.2

This commit is contained in:
TangJR
2016-04-10 19:11:30 +08:00
parent 1183b3a790
commit 9522480e31

View File

@ -5,13 +5,20 @@
> 翻译:[shinyzhu](https://github.com/shinyzhu) > 翻译:[shinyzhu](https://github.com/shinyzhu)
> 校对:[pp-prog](https://github.com/pp-prog) [yangsiy](https://github.com/yangsiy) > 校对:[pp-prog](https://github.com/pp-prog) [yangsiy](https://github.com/yangsiy)
> 2.0 > 2.0
> 翻译+校对:[yangsiy](https://github.com/yangsiy) > 翻译+校对:[yangsiy](https://github.com/yangsiy)
> 2.1 > 2.1
> 翻译:[buginux](https://github.com/buginux) > 翻译:[buginux](https://github.com/buginux)
> 校对:[shanks](http://codebuild.me)2015-10-29 > 校对:[shanks](http://codebuild.me)2015-10-29
> 2.2
>
> 翻译:[saitjr](https://github.com/saitjr)
本页包含内容: 本页包含内容:
- [存储属性Stored Properties](#stored_properties) - [存储属性Stored Properties](#stored_properties)
@ -280,8 +287,9 @@ stepCounter.totalSteps = 896
`didSet`观察器在`totalSteps`的值改变后被调用,它把新值和旧值进行对比,如果总步数增加了,就输出一个消息表示增加了多少步。`didSet`没有为旧值提供自定义名称,所以默认值`oldValue`表示旧值的参数名。 `didSet`观察器在`totalSteps`的值改变后被调用,它把新值和旧值进行对比,如果总步数增加了,就输出一个消息表示增加了多少步。`didSet`没有为旧值提供自定义名称,所以默认值`oldValue`表示旧值的参数名。
> 注意 >注意
> 如果在一个属性的`didSet`观察器里为它赋值,这个值会替换之前设置的值。 >
>如果将属性通过 in-out 方式传入函数,`willSet` 和 `didSet` 也会调用。这是因为 in-out 参数采用了拷入拷出模式:即在函数内部使用的是参数的 copy函数结束后又对参数重新赋值。关于 in-out 参数详细的介绍,请参考[输入输出参数](../chapter3/05_Declarations.html#in-out_parameters)
<a name="global_and_local_variables"></a> <a name="global_and_local_variables"></a>
##全局变量和局部变量 ##全局变量和局部变量