From 687b45c73a38af40cdf2f4938881be56e7da26db Mon Sep 17 00:00:00 2001 From: Charles Magahern Date: Sat, 30 Jul 2016 21:41:41 -0700 Subject: [PATCH] Fix crash on iPhone when tapping ALL ON or ALL OFF --- .../Controllers/SwitchesViewController.swift | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/XIONControlPanel/Controllers/SwitchesViewController.swift b/XIONControlPanel/Controllers/SwitchesViewController.swift index af43596..9a20595 100644 --- a/XIONControlPanel/Controllers/SwitchesViewController.swift +++ b/XIONControlPanel/Controllers/SwitchesViewController.swift @@ -211,14 +211,15 @@ class SwitchesViewController: UIViewController, var currentDelay: NSTimeInterval = 0.0 for i in ActionCell.count ..< collectionView.numberOfItemsInSection(indexPath.section) { - let cell = collectionView.cellForItemAtIndexPath(NSIndexPath(forItem: i, inSection: indexPath.section)) as! WemoDeviceCellView - let animOptions = UIViewAnimationOptions([.AllowUserInteraction]) - - UIView.animateWithDuration(0.3, delay: currentDelay, options: animOptions, animations: { - cell.toggled = (tappedActionCell == .AllOn) - }, completion: nil) - - currentDelay += 0.05 + if let cell = collectionView.cellForItemAtIndexPath(NSIndexPath(forItem: i, inSection: indexPath.section)) as? WemoDeviceCellView { + let animOptions = UIViewAnimationOptions([.AllowUserInteraction]) + + UIView.animateWithDuration(0.3, delay: currentDelay, options: animOptions, animations: { + cell.toggled = (tappedActionCell == .AllOn) + }, completion: nil) + + currentDelay += 0.05 + } } for device in self.devices {