Switch back to AnyObject from AnyHashable, because of http://openradar.appspot.com/34824398

This commit is contained in:
Brent Simmons 2017-11-04 23:05:20 -07:00
parent e16911b363
commit 57296279e4
12 changed files with 34 additions and 40 deletions

View File

@ -40,7 +40,7 @@ final class AppInfo {
var article: Article?
var articles: Set<Article>?
var navigationKey: Int?
var objects: [AnyHashable]?
var objects: [AnyObject]?
var feed: Feed?
static let appInfoKey = "appInfo"

View File

@ -9,7 +9,7 @@
import Foundation
import RSCore
struct FeedListFeed: Hashable, DisplayNameProvider {
final class FeedListFeed: Hashable, DisplayNameProvider {
let name: String
let url: String
@ -37,7 +37,7 @@ struct FeedListFeed: Hashable, DisplayNameProvider {
static let homePageURL = "homePageURL"
}
init(dictionary: [String: String]) {
convenience init(dictionary: [String: String]) {
let name = (dictionary[Key.name] ?? dictionary[Key.editedName])!
let url = dictionary[Key.url]!

View File

@ -10,7 +10,7 @@ import Foundation
import RSCore
import Data
struct FeedListFolder: Hashable, DisplayNameProvider {
final class FeedListFolder: Hashable, DisplayNameProvider {
let name: String
let feeds: Set<FeedListFeed>

View File

@ -48,7 +48,7 @@ private extension FeedListTreeControllerDelegate {
func childNodesForRootNode(_ rootNode: Node) -> [Node]? {
let children = (Array(topLevelFeeds) as [AnyHashable]) + (Array(folders) as [AnyHashable])
let children = (Array(topLevelFeeds) as [AnyObject]) + (Array(folders) as [AnyObject])
return childNodesForContainerNode(rootNode, children)
}
@ -58,18 +58,18 @@ private extension FeedListTreeControllerDelegate {
return childNodesForContainerNode(folderNode, Array(folder.feeds))
}
func childNodesForContainerNode(_ containerNode: Node, _ children: [AnyHashable]) -> [Node]? {
func childNodesForContainerNode(_ containerNode: Node, _ children: [AnyObject]) -> [Node]? {
let nodes = unsortedNodes(parent: containerNode, children: children)
return Node.nodesSortedAlphabeticallyWithFoldersAtEnd(nodes)
}
func unsortedNodes(parent: Node, children: [AnyHashable]) -> [Node] {
func unsortedNodes(parent: Node, children: [AnyObject]) -> [Node] {
return children.map{ createNode(child: $0, parent: parent) }
}
func createNode(child: AnyHashable, parent: Node) -> Node {
func createNode(child: AnyObject, parent: Node) -> Node {
if let feed = child as? FeedListFeed {
return createNode(feed: feed, parent: parent)

View File

@ -34,16 +34,16 @@ private extension SidebarTreeControllerDelegate {
// This will be expanded later to add synthetic feeds (All Unread, for instance)
// and other accounts.
return childNodesForContainerNode(rootNode, AccountManager.shared.localAccount.children as! [AnyHashable])
return childNodesForContainerNode(rootNode, AccountManager.shared.localAccount.children)
}
func childNodesForFolderNode(_ folderNode: Node) -> [Node]? {
let folder = folderNode.representedObject as! Folder
return childNodesForContainerNode(folderNode, folder.children as! [AnyHashable])
return childNodesForContainerNode(folderNode, folder.children)
}
func childNodesForContainerNode(_ containerNode: Node, _ children: [AnyHashable]) -> [Node]? {
func childNodesForContainerNode(_ containerNode: Node, _ children: [AnyObject]) -> [Node]? {
var updatedChildNodes = [Node]()
@ -88,10 +88,10 @@ private extension SidebarTreeControllerDelegate {
return node
}
func nodeInArrayRepresentingObject(_ nodes: [Node], _ representedObject: AnyHashable) -> Node? {
func nodeInArrayRepresentingObject(_ nodes: [Node], _ representedObject: AnyObject) -> Node? {
for oneNode in nodes {
if oneNode.representedObject == representedObject {
if oneNode.representedObject === representedObject {
return oneNode
}
}

View File

@ -39,10 +39,10 @@ import RSCore
@objc dynamic func unreadCountDidChange(_ note: Notification) {
guard let representedObject = note.object as? AnyHashable else {
guard let representedObject = note.object else {
return
}
let _ = configureCellsForRepresentedObject(representedObject)
let _ = configureCellsForRepresentedObject(representedObject as AnyObject)
}
@objc dynamic func containerChildrenDidChange(_ note: Notification) {
@ -176,7 +176,7 @@ private extension SidebarViewController {
}
}
func postSidebarSelectionDidChangeNotification(_ selectedObjects: [AnyHashable]?) {
func postSidebarSelectionDidChangeNotification(_ selectedObjects: [AnyObject]?) {
let appInfo = AppInfo()
if let objects = selectedObjects {
@ -190,7 +190,7 @@ private extension SidebarViewController {
NotificationCenter.default.post(name: .SidebarSelectionDidChange, object: self, userInfo: appInfo.userInfo)
}
func updateUnreadCounts(for objects: [AnyHashable]) {
func updateUnreadCounts(for objects: [AnyObject]) {
// On selection, update unread counts for folders and feeds.
// For feeds, actually fetch from database.
@ -304,7 +304,7 @@ private extension SidebarViewController {
return cells
}
func cellsForRepresentedObject(_ representedObject: AnyHashable) -> [SidebarCell] {
func cellsForRepresentedObject(_ representedObject: AnyObject) -> [SidebarCell] {
let availableCells = availableSidebarCells()
return availableCells.filter{ (oneSidebarCell) -> Bool in
@ -312,11 +312,11 @@ private extension SidebarViewController {
guard let oneNode = oneSidebarCell.objectValue as? Node else {
return false
}
return oneNode.representedObject == representedObject
return oneNode.representedObject === representedObject
}
}
func configureCellsForRepresentedObject(_ representedObject: AnyHashable) -> Bool {
func configureCellsForRepresentedObject(_ representedObject: AnyObject) -> Bool {
//Return true if any cells were configured.
@ -337,7 +337,7 @@ private extension SidebarViewController {
}
@discardableResult
func revealAndSelectRepresentedObject(_ representedObject: AnyHashable) -> Bool {
func revealAndSelectRepresentedObject(_ representedObject: AnyObject) -> Bool {
return outlineView.revealAndSelectRepresentedObject(representedObject, treeController)
}

View File

@ -43,7 +43,7 @@ class TimelineViewController: NSViewController, KeyboardDelegate, UndoableComman
}
}
private var representedObjects: [AnyHashable]? {
private var representedObjects: [AnyObject]? {
didSet {
if !representedObjectArraysAreEqual(oldValue, representedObjects) {
fetchArticles()
@ -449,7 +449,7 @@ private extension TimelineViewController {
}
}
func representedObjectArraysAreEqual(_ objects1: [AnyHashable]?, _ objects2: [AnyHashable]?) -> Bool {
func representedObjectArraysAreEqual(_ objects1: [AnyObject]?, _ objects2: [AnyObject]?) -> Bool {
if objects1 == nil && objects2 == nil {
return true
@ -463,7 +463,7 @@ private extension TimelineViewController {
var ix = 0
for oneObject in objects1 {
if oneObject != objects2[ix] {
if oneObject !== objects2[ix] {
return false
}
ix += 1

View File

@ -44,7 +44,7 @@ public extension NSOutlineView {
}
@discardableResult
public func revealAndSelectRepresentedObject(_ representedObject: AnyHashable, _ treeController: TreeController) -> Bool {
public func revealAndSelectRepresentedObject(_ representedObject: AnyObject, _ treeController: TreeController) -> Bool {
guard let nodePath = NodePath(representedObject: representedObject, treeController: treeController) else {
return false

View File

@ -11,7 +11,7 @@ import Foundation
public final class Node: Equatable {
public weak var parent: Node?
public let representedObject: AnyHashable
public let representedObject: AnyObject
public var canHaveChildNodes = false
public var isGroupItem = false
public var childNodes: [Node]?
@ -59,7 +59,7 @@ public final class Node: Equatable {
}
}
public init(representedObject: AnyHashable, parent: Node?) {
public init(representedObject: AnyObject, parent: Node?) {
self.representedObject = representedObject
self.parent = parent
@ -90,14 +90,14 @@ public final class Node: Equatable {
}
}
public func childNodeRepresentingObject(_ obj: AnyHashable) -> Node? {
public func childNodeRepresentingObject(_ obj: AnyObject) -> Node? {
guard let childNodes = childNodes else {
return nil
}
for oneNode in childNodes {
if oneNode.representedObject == obj {
if oneNode.representedObject === obj {
return oneNode
}
}

View File

@ -30,7 +30,7 @@ public struct NodePath {
self.components = tempArray.reversed()
}
public init?(representedObject: AnyHashable, treeController: TreeController) {
public init?(representedObject: AnyObject, treeController: TreeController) {
if let node = treeController.nodeInTreeRepresentingObject(representedObject) {
self.init(node: node)

View File

@ -10,12 +10,6 @@ import Foundation
// Handy to use as the represented object for a root node. Not required to use it, though.
final class TopLevelRepresentedObject: Hashable {
final class TopLevelRepresentedObject {
let hashValue: Int = 0
static func ==(lhs: TopLevelRepresentedObject, rhs: TopLevelRepresentedObject) -> Bool {
return true
}
}

View File

@ -45,11 +45,11 @@ public final class TreeController {
visitNode(rootNode, visitBlock)
}
public func nodeInArrayRepresentingObject(nodes: [Node], representedObject: AnyHashable, recurse: Bool = false) -> Node? {
public func nodeInArrayRepresentingObject(nodes: [Node], representedObject: AnyObject, recurse: Bool = false) -> Node? {
for oneNode in nodes {
if oneNode.representedObject == representedObject {
if oneNode.representedObject === representedObject {
return oneNode
}
@ -63,7 +63,7 @@ public final class TreeController {
return nil
}
public func nodeInTreeRepresentingObject(_ representedObject: AnyHashable) -> Node? {
public func nodeInTreeRepresentingObject(_ representedObject: AnyObject) -> Node? {
return nodeInArrayRepresentingObject(nodes: [rootNode], representedObject: representedObject, recurse: true)
}