Skip to content

Commit

Permalink
Merge pull request #4 from jgonfer/1.1.1
Browse files Browse the repository at this point in the history
1.1.1 -> master
  • Loading branch information
jgonfer committed Feb 17, 2017
2 parents d65f63f + 2c538dd commit fb13a10
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions touch 3d/touch 3d/AnimalsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class AnimalsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

setupView()
if animals == nil {
setupView()
}

if traitCollection.forceTouchCapability == .available {
registerForPreviewing(with: self, sourceView: view)
Expand All @@ -38,6 +40,7 @@ class AnimalsViewController: UIViewController {
super.viewWillAppear(animated)

guard let index = selectedIndex else {
tableView.reloadData()
return
}
updateAnimalState(atIndex: index)
Expand All @@ -63,10 +66,10 @@ class AnimalsViewController: UIViewController {
selectedIndex = IndexPath(row: 1, section: 0)
performSegue(withIdentifier: segueIdentifier, sender: nil)
case .OpenRandomAnimal:
guard let animals = self.animals else {
return false
if animals == nil {
setupView()
}
let randomNumber = Int(arc4random_uniform(UInt32(animals.count)))
let randomNumber = Int(arc4random_uniform(UInt32(animals!.count)))
selectedIndex = IndexPath(row: randomNumber, section: 0)
performSegue(withIdentifier: segueIdentifier, sender: nil)
default:
Expand Down

0 comments on commit fb13a10

Please sign in to comment.