Updates syntax to Swift 3 Beta 2 via Xcode migrator

This commit is contained in:
Riley Testut 2016-07-27 12:57:23 -05:00
parent aa2a895d74
commit ae1d3f61dd
11 changed files with 28 additions and 19 deletions

View File

@ -62,7 +62,7 @@ class GridCollectionViewLayout: UICollectionViewFlowLayout
} }
} }
if let maxY = maximumY, minY = minimumY if let maxY = maximumY, let minY = minimumY
{ {
// If attributes.frame.minY is greater than maximumY, then it is a new row // If attributes.frame.minY is greater than maximumY, then it is a new row
// In this case, we need to align all the previous tempLayoutAttributes to the same Y-value // In this case, we need to align all the previous tempLayoutAttributes to the same Y-value

View File

@ -56,7 +56,7 @@ public extension LoadImageOperation
let options: NSDictionary = [kCGImageSourceShouldCache as NSString: true] let options: NSDictionary = [kCGImageSourceShouldCache as NSString: true]
if let imageSource = CGImageSourceCreateWithURL(self.URL, options), quartzImage = CGImageSourceCreateImageAtIndex(imageSource, 0, options) if let imageSource = CGImageSourceCreateWithURL(self.URL, options), let quartzImage = CGImageSourceCreateImageAtIndex(imageSource, 0, options)
{ {
let loadedImage = UIImage(cgImage: quartzImage) let loadedImage = UIImage(cgImage: quartzImage)

View File

@ -60,8 +60,9 @@ class DatabaseManager
var performingMigration = false var performingMigration = false
if let sourceMetadata = try? NSPersistentStoreCoordinator.metadataForPersistentStore(ofType: NSSQLiteStoreType, at: storeURL, options: options), if
managedObjectModel = self.privateManagedObjectContext.persistentStoreCoordinator?.managedObjectModel let sourceMetadata = try? NSPersistentStoreCoordinator.metadataForPersistentStore(ofType: NSSQLiteStoreType, at: storeURL, options: options),
let managedObjectModel = self.privateManagedObjectContext.persistentStoreCoordinator?.managedObjectModel
{ {
performingMigration = !managedObjectModel.isConfiguration(withName: nil, compatibleWithStoreMetadata: sourceMetadata) performingMigration = !managedObjectModel.isConfiguration(withName: nil, compatibleWithStoreMetadata: sourceMetadata)
} }
@ -333,7 +334,10 @@ private extension DatabaseManager
@objc func managedObjectContextWillSave(_ notification: Notification) @objc func managedObjectContextWillSave(_ notification: Notification)
{ {
guard let managedObjectContext = notification.object as? NSManagedObjectContext where managedObjectContext.parent == self.validationManagedObjectContext else { return } guard
let managedObjectContext = notification.object as? NSManagedObjectContext,
managedObjectContext.parent == self.validationManagedObjectContext
else { return }
self.validationManagedObjectContext.performAndWait { self.validationManagedObjectContext.performAndWait {
self.validateManagedObjectContextSave(managedObjectContext) self.validateManagedObjectContextSave(managedObjectContext)
@ -342,7 +346,10 @@ private extension DatabaseManager
@objc func managedObjectContextDidSave(_ notification: Notification) @objc func managedObjectContextDidSave(_ notification: Notification)
{ {
guard let managedObjectContext = notification.object as? NSManagedObjectContext where managedObjectContext.parent == self.validationManagedObjectContext else { return } guard
let managedObjectContext = notification.object as? NSManagedObjectContext,
managedObjectContext.parent == self.validationManagedObjectContext
else { return }
self.save() self.save()
} }

@ -1 +1 @@
Subproject commit 790b007ce329c76783cafe1cd69259b5758186cd Subproject commit ce0e9ca96363ce5bc9280480d1c06563138df544

View File

@ -116,7 +116,7 @@ extension GameViewController
override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?)
{ {
guard let identifier = segue.identifier where identifier == "pause" else { return } guard let identifier = segue.identifier, identifier == "pause" else { return }
guard let gameController = sender as? GameController else { guard let gameController = sender as? GameController else {
fatalError("sender for pauseSegue must be the game controller that pressed the Menu button") fatalError("sender for pauseSegue must be the game controller that pressed the Menu button")

View File

@ -137,7 +137,7 @@ private extension GamesViewController
{ {
func viewControllerForIndex(_ index: Int) -> GamesCollectionViewController? func viewControllerForIndex(_ index: Int) -> GamesCollectionViewController?
{ {
guard let pages = self.fetchedResultsController.sections?.first?.numberOfObjects where pages > 0 else { return nil } guard let pages = self.fetchedResultsController.sections?.first?.numberOfObjects, pages > 0 else { return nil }
// Return nil if only one section, and not asking for the 0th view controller // Return nil if only one section, and not asking for the 0th view controller
guard !(pages == 1 && index != 0) else { return nil } guard !(pages == 1 && index != 0) else { return nil }

View File

@ -42,7 +42,7 @@ extension CheatTextView
{ {
super.layoutSubviews() super.layoutSubviews()
if let format = self.cheatFormat, font = self.font if let format = self.cheatFormat, let font = self.font
{ {
let characterWidth = ("A" as NSString).size(attributes: [NSFontAttributeName: font]).width let characterWidth = ("A" as NSString).size(attributes: [NSFontAttributeName: font]).width
@ -73,11 +73,11 @@ private extension CheatTextView
var string: NSString? = nil var string: NSString? = nil
scanner.scanCharacters(from: CharacterSet.alphanumerics, into: &string) scanner.scanCharacters(from: CharacterSet.alphanumerics, into: &string)
guard let scannedString = string where scannedString.length > 0 else { break } guard let scannedString = string, scannedString.length > 0 else { break }
let attributedString = NSMutableAttributedString(string: scannedString as String) let attributedString = NSMutableAttributedString(string: scannedString as String)
if let prefixString = prefixString where prefixString.length > 0 if let prefixString = prefixString, prefixString.length > 0
{ {
attributedString.addAttribute(CheatPrefixAttribute, value: prefixString, range: NSRange(location: 0, length: 1)) attributedString.addAttribute(CheatPrefixAttribute, value: prefixString, range: NSRange(location: 0, length: 1))
} }

View File

@ -95,7 +95,7 @@ private extension CheatsViewController
func updateBackgroundView() func updateBackgroundView()
{ {
if let fetchedObjects = self.fetchedResultsController.fetchedObjects where fetchedObjects.count > 0 if let fetchedObjects = self.fetchedResultsController.fetchedObjects, fetchedObjects.count > 0
{ {
self.tableView.separatorStyle = .singleLine self.tableView.separatorStyle = .singleLine
self.backgroundView.isHidden = true self.backgroundView.isHidden = true

View File

@ -32,7 +32,7 @@ class PausePresentationController: UIPresentationController
super.init(presentedViewController: presentedViewController, presenting: presentingViewController) super.init(presentedViewController: presentedViewController, presenting: presentingViewController)
self.contentView = Bundle.main.loadNibNamed("PausePresentationControllerContentView", owner: self, options: nil).first as! UIView self.contentView = Bundle.main.loadNibNamed("PausePresentationControllerContentView", owner: self, options: nil)?.first as! UIView
} }
override func frameOfPresentedViewInContainerView() -> CGRect override func frameOfPresentedViewInContainerView() -> CGRect
@ -61,7 +61,9 @@ class PausePresentationController: UIPresentationController
{ {
self.pauseLabel.text = provider.pauseText self.pauseLabel.text = provider.pauseText
} }
else if let navigationController = self.presentedViewController as? UINavigationController, provider = navigationController.topViewController as? PauseInfoProviding else if
let navigationController = self.presentedViewController as? UINavigationController,
let provider = navigationController.topViewController as? PauseInfoProviding
{ {
self.pauseLabel.text = provider.pauseText self.pauseLabel.text = provider.pauseText
} }

View File

@ -169,7 +169,7 @@ private extension SaveStatesViewController
func updateBackgroundView() func updateBackgroundView()
{ {
if let fetchedObjects = self.fetchedResultsController.fetchedObjects where fetchedObjects.count > 0 if let fetchedObjects = self.fetchedResultsController.fetchedObjects, fetchedObjects.count > 0
{ {
self.backgroundView.isHidden = true self.backgroundView.isHidden = true
} }
@ -587,8 +587,8 @@ extension SaveStatesViewController: UIViewControllerPreviewingDelegate, UIPrevie
{ {
guard guard
let indexPath = self.collectionView?.indexPathForItem(at: location), let indexPath = self.collectionView?.indexPathForItem(at: location),
let layoutAttributes = self.collectionViewLayout.layoutAttributesForItem(at: indexPath) let layoutAttributes = self.collectionViewLayout.layoutAttributesForItem(at: indexPath),
where self.emulatorCoreSaveState != nil self.emulatorCoreSaveState != nil
else { return nil } else { return nil }
previewingContext.sourceRect = layoutAttributes.frame previewingContext.sourceRect = layoutAttributes.frame

View File

@ -71,7 +71,7 @@ class ControllersSettingsViewController: UITableViewController
controllers.append(self.localDeviceController) controllers.append(self.localDeviceController)
// Reset previous controller // Reset previous controller
if let playerIndex = self.playerIndex, index = controllers.index(where: { $0.playerIndex == playerIndex }) if let playerIndex = self.playerIndex, let index = controllers.index(where: { $0.playerIndex == playerIndex })
{ {
let controller = controllers[index] let controller = controllers[index]
controller.playerIndex = nil controller.playerIndex = nil