Created
October 30, 2016 18:01
-
-
Save kzkaed/b02f183405b791afe9f678f2f14ac3bf to your computer and use it in GitHub Desktop.
swift image iterator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var currentImagePosition = 0 | |
let images = ["Katherine_Johnson.jpg", | |
"Margaret_Hamilton.jpg", | |
"Grace_Hopper.jpg", | |
"Barbara_Liskov.jpg", | |
"Ellen_Ochoa.jpg", | |
"Latanya_Sweeney.jpg"] | |
func getNextImage() -> String { | |
currentImagePosition = self.currentImagePosition + 1 | |
if (currentImagePosition == images.count - 1) { | |
self.currentImagePosition = 0 | |
} | |
return images[currentImagePosition] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment