From c74201d1632859ae1ab570a4a7fff7d5ca184aea Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 17 Sep 2017 17:12:42 -0700 Subject: [PATCH] Continue fixing build errors. --- Evergreen/AppDelegate.swift | 40 ++----------------- .../Sidebar/SidebarViewController.swift | 2 +- .../Timeline/TimelineViewController.swift | 14 +++---- 3 files changed, 11 insertions(+), 45 deletions(-) diff --git a/Evergreen/AppDelegate.swift b/Evergreen/AppDelegate.swift index 37208c65a..ad1c704fa 100644 --- a/Evergreen/AppDelegate.swift +++ b/Evergreen/AppDelegate.swift @@ -13,6 +13,7 @@ import RSTextDrawing import RSTree import RSParser import RSWeb +import Account var currentTheme: VSTheme! @@ -40,40 +41,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { super.init() } - private func evergreenImage() -> NSImage? { - var image: NSImage? = nil - let imageWidth = 1024 - let imageHeight = 1024 - let imageSize = NSMakeSize(CGFloat(imageWidth), CGFloat(imageHeight)) - - if let drawingContext = CGContext(data: nil, width: imageWidth, height: imageHeight, bitsPerComponent: 8, bytesPerRow: 0, space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: CGImageAlphaInfo.premultipliedFirst.rawValue) { - - let graphicsContext = NSGraphicsContext(cgContext: drawingContext, flipped: false) - NSGraphicsContext.saveGraphicsState() - NSGraphicsContext.setCurrent(graphicsContext) - - let targetRect = NSRect(origin: NSZeroPoint, size: imageSize) - NSString(string: "🌲").draw(in: targetRect, withAttributes: [NSFontAttributeName: NSFont.systemFont(ofSize: 1000)]) - - NSGraphicsContext.restoreGraphicsState() - - if let coreImage = drawingContext.makeImage() { - image = NSImage(cgImage: coreImage, size: imageSize) - } - } - - return image - } - // MARK: NSApplicationDelegate func applicationDidFinishLaunching(_ note: Notification) { - if let appIconImage = evergreenImage() { - appIconImage.setName("NSApplicationIcon") - NSApplication.shared().applicationIconImage = appIconImage - } - registerDefaults() currentTheme = themeLoader.defaultTheme @@ -90,9 +61,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { importDefaultFeedsIfNeeded(isFirstRun, account: AccountManager.sharedInstance.localAccount) createAndShowMainWindow() - NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) - AccountManager.sharedInstance.updateUnreadCount() - #if RELEASE DispatchQueue.main.async { self.refreshAll(self) @@ -120,7 +88,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { // MARK: GetURL Apple Event - func getURL(_ event: NSAppleEventDescriptor, _ withReplyEvent: NSAppleEventDescriptor) { + @objc func getURL(_ event: NSAppleEventDescriptor, _ withReplyEvent: NSAppleEventDescriptor) { guard let urlString = event.paramDescriptor(forKeyword: keyDirectObject)?.stringValue else { return @@ -148,7 +116,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { @objc dynamic func updateBadge() { let label = unreadCount > 0 ? "\(unreadCount)" : "" - NSApplication.shared().dockTile.badgeLabel = label + NSApplication.shared.dockTile.badgeLabel = label } // MARK: Notifications @@ -165,7 +133,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { func windowControllerWithName(_ storyboardName: String) -> NSWindowController { - let storyboard = NSStoryboard(name: storyboardName, bundle: nil) + let storyboard = NSStoryboard(name: NSStoryboard.Name(rawValue: storyboardName), bundle: nil) return storyboard.instantiateInitialController()! as! NSWindowController } diff --git a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift index 14a6d8f8e..9e5ea3b5a 100644 --- a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift +++ b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift @@ -110,7 +110,7 @@ import Account func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? { - let cell = outlineView.make(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "DataCell"), owner: self) as! SidebarCell + let cell = outlineView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "DataCell"), owner: self) as! SidebarCell let node = item as! Node configure(cell, node) diff --git a/Evergreen/MainWindow/Timeline/TimelineViewController.swift b/Evergreen/MainWindow/Timeline/TimelineViewController.swift index eef85a408..8c4d5bcc3 100644 --- a/Evergreen/MainWindow/Timeline/TimelineViewController.swift +++ b/Evergreen/MainWindow/Timeline/TimelineViewController.swift @@ -357,9 +357,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView private func rowForArticle(_ article: Article) -> Int { - if let index = articles.index(where: { (oneArticle) -> Bool in - return oneArticle === article - }) { + if let index = articles.index(where: { $0.articleID == article.articleID }) { return index } @@ -406,9 +404,9 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView for oneObject in representedObjects { if let oneFeed = oneObject as? Feed { - addToAccountArray(accountID: oneFeed.account.identifier, object: oneFeed) + addToAccountArray(accountID: oneFeed.account.accountID, object: oneFeed) } - else if let oneFolder = oneObject as? Folder, let accountID = oneFolder.account?.identifier { + else if let oneFolder = oneObject as? Folder, let accountID = oneFolder.account?.accountID { addToAccountArray(accountID: accountID, object: oneFolder) } } @@ -478,14 +476,14 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? { - let rowView: TimelineTableRowView = tableView.make(withIdentifier: "timelineRow", owner: self) as! TimelineTableRowView + let rowView: TimelineTableRowView = tableView.make(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "timelineRow"), owner: self) as! TimelineTableRowView rowView.cellAppearance = cellAppearance return rowView } func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { - let cell: TimelineTableCellView = tableView.make(withIdentifier: "timelineCell", owner: self) as! TimelineTableCellView + let cell: TimelineTableCellView = tableView.make(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "timelineCell"), owner: self) as! TimelineTableCellView cell.cellAppearance = cellAppearance if let article = articleAtRow(row) { @@ -502,7 +500,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView var userInfo = [String: AnyObject]() if let article = selectedArticle { - userInfo[articleKey] = article + userInfo[articleKey] = article as AnyObject } userInfo[viewKey] = self.tableView