Created
October 26, 2016 21:42
-
-
Save tgaul/e95a78646ddb4936ef515cffebfeecba to your computer and use it in GitHub Desktop.
Patch to get Crafting Modern Cocoa Apps WWDC session app (https://developer.apple.com/library/prerelease/content/samplecode/PhotoEditor/Introduction/Intro.html#//apple_ref/doc/uid/TP40017384) compiling without errors in Xcode 8.1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 94e6ad1869622652b9752e410f3dc24a02bca0f0 Mon Sep 17 00:00:00 2001 | |
From: Troy Gaul <[email protected]> | |
Date: Wed, 26 Oct 2016 16:37:43 -0500 | |
Subject: [PATCH] Changes to get compiling with Xcode 8.1. | |
--- | |
Photo Editor/CanvasViewController.swift | 2 +- | |
Photo Editor/PhotoController.swift | 2 +- | |
Photo Editor/PhotoDocumentWindowController.swift | 4 ++-- | |
Photo Editor/SidebarViewController.swift | 8 ++++---- | |
4 files changed, 8 insertions(+), 8 deletions(-) | |
diff --git a/Photo Editor/CanvasViewController.swift b/Photo Editor/CanvasViewController.swift | |
index ca34309..d692845 100644 | |
--- a/Photo Editor/CanvasViewController.swift | |
+++ b/Photo Editor/CanvasViewController.swift | |
@@ -38,7 +38,7 @@ class CanvasViewController: NSViewController, PhotoControllerConsumer { | |
if topTextFieldConstraint == nil { | |
// Keep the text field aligned underneath the title/toolbar area via the contentLayoutGuide | |
// The titleTextField has a y constraint that is set to be removed at build time in order to not conflict with this constraint. | |
- if let contentAnchor = titleTextField.window?.contentLayoutGuide?.topAnchor { | |
+ if let contentAnchor = (titleTextField.window?.contentLayoutGuide as AnyObject?)?.topAnchor { | |
topTextFieldConstraint = titleTextField.topAnchor.constraint(equalTo: contentAnchor, constant: 2) | |
topTextFieldConstraint?.isActive = true | |
} | |
diff --git a/Photo Editor/PhotoController.swift b/Photo Editor/PhotoController.swift | |
index 4752069..d02cbd6 100644 | |
--- a/Photo Editor/PhotoController.swift | |
+++ b/Photo Editor/PhotoController.swift | |
@@ -29,7 +29,7 @@ class PhotoController: NSObject { | |
subscribers.remove(subscriber) | |
} | |
- private func forEachSubscriber(_ work: @noescape (PhotoSubscriber) -> Void) { | |
+ private func forEachSubscriber(_ work: (PhotoSubscriber) -> Void) { | |
for object in subscribers.objectEnumerator() { | |
guard let subscriber = object as? PhotoSubscriber else { continue } | |
work(subscriber) | |
diff --git a/Photo Editor/PhotoDocumentWindowController.swift b/Photo Editor/PhotoDocumentWindowController.swift | |
index de932bd..909646e 100644 | |
--- a/Photo Editor/PhotoDocumentWindowController.swift | |
+++ b/Photo Editor/PhotoDocumentWindowController.swift | |
@@ -25,7 +25,7 @@ class PhotoDocumentWindowController: NSWindowController, NSWindowDelegate { | |
@IBOutlet weak var modeSelectionControl: NSSegmentedControl! | |
- private var splitViewController: PhotoSplitViewController! { return contentViewController as? PhotoSplitViewController } | |
+ fileprivate var splitViewController: PhotoSplitViewController! { return contentViewController as? PhotoSplitViewController } | |
private var drawAccessoryViewController: NSTitlebarAccessoryViewController! | |
private var effectsAccessoryViewController: EffectsAccessoryViewController! | |
@@ -254,7 +254,7 @@ extension PhotoDocumentWindowController: PhotoSubscriber { | |
func photo(_ photo: Photo, didChangeImage image: NSImage?, from oldImage: NSImage?) { | |
if let document = self.document { | |
if let undoManager = document.undoManager { | |
- undoManager?.registerUndoWithTarget(self) { targetType in | |
+ undoManager?.registerUndo(withTarget: self) { targetType in | |
targetType.photoController?.setPhotoImage(oldImage) | |
} | |
} | |
diff --git a/Photo Editor/SidebarViewController.swift b/Photo Editor/SidebarViewController.swift | |
index 51192ed..b8041a2 100644 | |
--- a/Photo Editor/SidebarViewController.swift | |
+++ b/Photo Editor/SidebarViewController.swift | |
@@ -15,8 +15,8 @@ class SidebarViewController: NSViewController, PhotoControllerConsumer { | |
@IBOutlet weak var sidebarScrollView: NSScrollView! | |
// An array of titles to show and icons (images) | |
- private var tableContents: [ImageItem] = [ImageItem]() | |
- private var filteredTableContents: [ImageItem] = [ImageItem]() | |
+ fileprivate var tableContents: [ImageItem] = [ImageItem]() | |
+ fileprivate var filteredTableContents: [ImageItem] = [ImageItem]() | |
private var bookmarkData: Data? | |
private var searchContainerViewHeight: CGFloat = 0.0 | |
private var appearanceObservationToken: NSObjectProtocol? | |
@@ -140,7 +140,7 @@ class SidebarViewController: NSViewController, PhotoControllerConsumer { | |
} | |
} | |
- override func observeValue(forKeyPath keyPath: String?, of object: AnyObject?, change: [NSKeyValueChangeKey : AnyObject]?, context: UnsafeMutablePointer<Void>?) { | |
+ override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { | |
precondition(keyPath! == "contentLayoutRect", "We are only observing the contentLayoutRect") | |
updateScrollViewContentInsets() | |
} | |
@@ -312,7 +312,7 @@ extension SidebarViewController: NSTableViewDelegate, NSTableViewDataSource { | |
// Demonstrate drag flocking in a table | |
func tableView(_ tableView: NSTableView, pasteboardWriterForRow row: Int) -> NSPasteboardWriting? { | |
let imageItem = filteredTableContents[row] | |
- return imageItem.url | |
+ return imageItem.url as NSURL | |
} | |
func tableViewSelectionDidChange(_ notification: Notification) { | |
-- | |
2.6.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment