Skip to content

Instantly share code, notes, and snippets.

@000Dmyers000
Created July 27, 2016 14:52
Show Gist options
  • Save 000Dmyers000/646d2b972ae05ec59ceead13d8e95272 to your computer and use it in GitHub Desktop.
Save 000Dmyers000/646d2b972ae05ec59ceead13d8e95272 to your computer and use it in GitHub Desktop.
I would like to control an array in sequence for back and next buttons, right now it selects the items randomly "Int(arc4random_uniform)" how can I change this? (I have not added the else/if functions yet)
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var slide: UIImageView!
@IBOutlet weak var playNextButton: UIButton!
var slideArray:[String] = ["slide1", "slide2", "slide3", "slide4"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func nextButton(sender: UIButton) {
let slide = Int(arc4random_uniform(4))
let slideString:String = self.slideArray [slide]
self.slide.image = UIImage(named: slideString)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment