Skip to content

Commit fb13a10

Browse files
authored
Merge pull request #4 from jgonfer/1.1.1
1.1.1 -> master
2 parents d65f63f + 2c538dd commit fb13a10

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

touch 3d/touch 3d/AnimalsViewController.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ class AnimalsViewController: UIViewController {
2727
override func viewDidLoad() {
2828
super.viewDidLoad()
2929

30-
setupView()
30+
if animals == nil {
31+
setupView()
32+
}
3133

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

4042
guard let index = selectedIndex else {
43+
tableView.reloadData()
4144
return
4245
}
4346
updateAnimalState(atIndex: index)
@@ -63,10 +66,10 @@ class AnimalsViewController: UIViewController {
6366
selectedIndex = IndexPath(row: 1, section: 0)
6467
performSegue(withIdentifier: segueIdentifier, sender: nil)
6568
case .OpenRandomAnimal:
66-
guard let animals = self.animals else {
67-
return false
69+
if animals == nil {
70+
setupView()
6871
}
69-
let randomNumber = Int(arc4random_uniform(UInt32(animals.count)))
72+
let randomNumber = Int(arc4random_uniform(UInt32(animals!.count)))
7073
selectedIndex = IndexPath(row: randomNumber, section: 0)
7174
performSegue(withIdentifier: segueIdentifier, sender: nil)
7275
default:

0 commit comments

Comments
 (0)