![iOS 12 Programming for Beginners](https://wfqqreader-1252317822.image.myqcloud.com/cover/76/36699076/b_36699076.jpg)
上QQ阅读APP看书,第一时间看更新
Iterating over an array
It would be nice if we could see a list of states in our array. Earlier, you learned that for...in loops work with sequences. Since our array is a sequence, we can use for...in loops to loop through each element. When working on a project that has arrays, it is helpful to use a print statement inside a for...in loop. This lets us print every item in our array to the Debug Panel. So, let's use a for...in loop to look at the contents of our array:
for state in states { print(state) }
This is how our code and output should now look:
![](https://epubservercos.yuewen.com/2E52D1/19470383901517806/epubprivate/OEBPS/Images/81bda9c9-a688-4a81-afd5-97ccdf37eb79.png?sign=1738844802-X20p0YxxR612qAMUwcy0xiH6gPVUxAmv-0-6569c6fd1699ce8a3d57b4749b9876e1)