fix 2.4 collection types

This commit is contained in:
stanzhai
2014-06-15 09:27:29 +08:00
parent 4dc52f3174
commit 773f9909cd
2 changed files with 72 additions and 65 deletions

View File

@ -27,42 +27,59 @@ lifedim说他平时12点就会睡1点47分发给我校对后的文档。
全体人员名单(排名不分先后): 全体人员名单(排名不分先后):
- numbbbbb - [numbbbbb](https://github.com/numbbbbb)
- coverxit - [stanzhai](https://github.com/stanzhai)
- wh1100717 - [coverxit](https://github.com/coverxit)
- TimothyYe - [wh1100717](https://github.com/wh1100717)
- honghaoz - [TimothyYe](https://github.com/TimothyYe)
- Hawstein - [honghaoz](https://github.com/honghaoz)
- JaySurplus - [lyuka](https://github.com/lyuka)
- stanzhai - [JaySurplus](https://github.com/JaySurplus)
- lyuka - [Hawstein](https://github.com/Hawstein)
- geek5nan - [geek5nan](https://github.com/geek5nan)
- xielingwang - [yankuangshi](https://github.com/yankuangshi)
- yankuangshi - [xielingwang](https://github.com/xielingwang)
- dabing1022 - [yulingtianxia](https://github.com/yulingtianxia)
- siemenliu - [twlkyao](https://github.com/twlkyao)
- fd5788 - [dabing1022](https://github.com/dabing1022)
- youkugems - [vclwei](https://github.com/vclwei)
- haolloyin - [fd5788](https://github.com/fd5788)
- superkam - [siemenliu](https://github.com/siemenliu)
- vclwei - [youkugems](https://github.com/youkugems)
- sg552 - [haolloyin](https://github.com/haolloyin)
- bzsy - [wxstars](https://github.com/wxstars)
- pyanfield - [IceskYsl](https://github.com/IceskYsl)
- ericzyh - [sg552](https://github.com/sg552)
- 088haizi - [superkam](https://github.com/superkam)
- viztor - [zac1st1k](https://github.com/zac1st1k)
- pp-prog - [bzsy](https://github.com/bzsy)
- baocaixiong - [pyanfield](https://github.com/pyanfield)
- marsprince - [ericzyh](https://github.com/ericzyh)
- shinyzhu - [peiyucn](https://github.com/peiyucn)
- happyming - [sunfiled](https://github.com/sunfiled)
- menlongsheng - [lzw120](https://github.com/lzw120)
- zq54zquan - [viztor](https://github.com/viztor)
- Evilcome - [wongzigii](https://github.com/wongzigii)
- lslxdx - [umcsdon](https://github.com/umcsdon)
- yeahdongcn - [zq54zquan](https://github.com/zq54zquan)
- zqp - [xiehurricane](https://github.com/xiehurricane)
- xiehurricane - [Jasonbroker](https://github.com/Jasonbroker)
- Jasonbroker - [tualatrix](https://github.com/tualatrix)
- aquaporcus - [pp-prog](https://github.com/pp-prog)
- [088haizi](https://github.com/088haizi)
- [baocaixiong](https://github.com/baocaixiong)
- [yeahdongcn](https://github.com/yeahdongcn)
- [shinyzhu](https://github.com/shinyzhu)
- [lslxdx](https://github.com/lslxdx)
- [Evilcome](https://github.com/Evilcome)
- [zqp](https://github.com/zqp)
- [NicePiao](https://github.com/NicePiao)
- [LunaticM](https://github.com/LunaticM)
- [menlongsheng](https://github.com/menlongsheng)
- [lifedim](https://github.com/lifedim)
- [happyming](https://github.com/happyming)
- [bruce0505](https://github.com/bruce0505)
- [Lin-H](https://github.com/Lin-H)
- [takalard](https://github.com/takalard)
- [ChildhoodAndy](https://github.com/ChildhoodAndy)
- [marsprince](https://github.com/marsprince)

View File

@ -1,5 +1,5 @@
> 翻译zqp > 翻译zqp
> 校对shinyzhu > 校对shinyzhu, stanzhai
# 集合类型 (Collection Types) # 集合类型 (Collection Types)
----------------- -----------------
@ -123,14 +123,8 @@ shoppingList[4...6] = ["Bananas", "Apples"]
// shoppingList 现在有六项 // shoppingList 现在有六项
``` ```
<<<<<<< HEAD
> 注意: > 注意:
>我们不能使用下标语法在数组尾部添加新项。如果我们试着用这种方法对索引越界的数据进行检索或者设置新值的操作,我们会引发一个运行期错误。我们可以使用索引值和数组的`count`属性进行比较来在使用某个索引之前先检验是否有效。除了当`count`等于 0 时(说明这是个空数组),最大索引值一直是`count - 1`,因为数组都是零起索引。 >我们不能使用下标语法在数组尾部添加新项。如果我们试着用这种方法对索引越界的数据进行检索或者设置新值的操作,我们会引发一个运行期错误。我们可以使用索引值和数组的`count`属性进行比较来在使用某个索引之前先检验是否有效。除了当`count`等于 0 时(说明这是个空数组),最大索引值一直是`count - 1`,因为数组都是零起索引。
=======
> 注意:
>
>我们不能使用下标语法在数组尾部添加新项。如果我们试着用这种方法对索引越界的数据进行检索或者设置新值的操作,我们会引发一个运行时错误。我们可以使用索引值和数组的`count`属性进行比较来在使用某个索引之前先检验是否有效。除了当`count`等于 0 时(说明这是个空数组),最大索引值一直是`count - 1`,因为数组都是零起索引。
>>>>>>> a516af6a531a104ec88da0d236ecf389a5ec72af
调用数组的`insert(atIndex:)`方法来在某个具体索引值之前添加数据项: 调用数组的`insert(atIndex:)`方法来在某个具体索引值之前添加数据项:
@ -364,6 +358,7 @@ for (airportCode, airportName) in airports {
// TYO: Tokyo // TYO: Tokyo
// LHR: London Heathrow // LHR: London Heathrow
``` ```
`for-in`循环请参见[For 循环](05_Control_Flow.html#for_loops)。 `for-in`循环请参见[For 循环](05_Control_Flow.html#for_loops)。
我们也可以通过访问它的`keys`或者`values`属性(都是可遍历集合)检索一个字典的键或者值: 我们也可以通过访问它的`keys`或者`values`属性(都是可遍历集合)检索一个字典的键或者值:
@ -374,9 +369,7 @@ for airportCode in airports.keys {
} }
// Airport code: TYO // Airport code: TYO
// Airport code: LHR // Airport code: LHR
```
```swift
for airportName in airports.values { for airportName in airports.values {
println("Airport name: \(airportName)") println("Airport name: \(airportName)")
} }
@ -389,9 +382,7 @@ for airportName in airports.values {
```swift ```swift
let airportCodes = Array(airports.keys) let airportCodes = Array(airports.keys)
// airportCodes is ["TYO", "LHR"] // airportCodes is ["TYO", "LHR"]
```
```swift
let airportNames = Array(airports.values) let airportNames = Array(airports.values)
// airportNames is ["Tokyo", "London Heathrow"] // airportNames is ["Tokyo", "London Heathrow"]
``` ```
@ -435,4 +426,3 @@ Swift 数组的可变性行为同时影响了数组实例如何被分配和修
> 注意: > 注意:
> 在我们不需要改变数组大小的时候创建不可变数组是很好的习惯。如此 Swift 编译器可以优化我们创建的集合。 > 在我们不需要改变数组大小的时候创建不可变数组是很好的习惯。如此 Swift 编译器可以优化我们创建的集合。