1

This is the code and wanna replace loop in my app:

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)
            }
        }

What would be the best and the most neat way to implement this loops in Swift?

Thanks in advance

Lion
  • 872
  • 1
  • 17
  • 43

0 Answers0