2014-09-24 41 views
0

我在早期的項目中使用它的非最終版本中使用快捷,並且上面的代碼工作得很好:斯威夫特過時..運營商創建陣列

for i in 0..array.count{ 
    //anything 
} 

當我下載了最終版本的錯誤:

use of uresolved identifier '..'

顯示出來。任何想法爲什麼?

回答

2

語法變爲此爲0至小於array.count

for i in 0..<array.count{ 
    //anything 
} 

,或者0到一個包括array.count

for i in 0...array.count{ 
    //anything 
} 
+1

您可能要解釋這兩個之間的區別... – 2014-09-24 03:25:30

1

-作爲張貼在offcial迅速來自Xcode 6 beta version 3的博客半開範圍的語法已更改。

因爲它說,在官方博客迅速:

The half-open range operator has been changed from .. to ..< to make it more clear alongside the ... operator for closed ranges.

按照新的語法:

for i in 0..<array.count{ 

    // Do something 

}