这是代码,想在我的应用中替换循环:
func loadVisiblePages() {
// First, determine which page is currently visible
let pageWidth = eventScrollView!.frame.size.width
let page = Int(floor((eventScrollView!.contentOffset.x * 2.0 + pageWidth) / (pageWidth * 2.0)))
// Work out which pages you want to load
let firstPage = page - 1
let lastPage = page + 1
// Purge anything before the first page
for var index = 0; index < firstPage; ++index {
purgePage(index)
}
// Load pages in our range
for index in firstPage...lastPage {
loadPage(index)
}
// Purge anything after the last page
for var index = lastPage+1; index < pageImages.count; index = index + 1 { //++index {
purgePage(index)
}
}
在Swift中实现此循环的最佳和最简洁的方法是什么?
提前致谢