Switch back to AnyObject from AnyHashable, because of http://openradar.appspot.com/34824398
This commit is contained in:
parent
e16911b363
commit
57296279e4
@ -40,7 +40,7 @@ final class AppInfo {
|
|||||||
var article: Article?
|
var article: Article?
|
||||||
var articles: Set<Article>?
|
var articles: Set<Article>?
|
||||||
var navigationKey: Int?
|
var navigationKey: Int?
|
||||||
var objects: [AnyHashable]?
|
var objects: [AnyObject]?
|
||||||
var feed: Feed?
|
var feed: Feed?
|
||||||
|
|
||||||
static let appInfoKey = "appInfo"
|
static let appInfoKey = "appInfo"
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import RSCore
|
import RSCore
|
||||||
|
|
||||||
struct FeedListFeed: Hashable, DisplayNameProvider {
|
final class FeedListFeed: Hashable, DisplayNameProvider {
|
||||||
|
|
||||||
let name: String
|
let name: String
|
||||||
let url: String
|
let url: String
|
||||||
@ -37,7 +37,7 @@ struct FeedListFeed: Hashable, DisplayNameProvider {
|
|||||||
static let homePageURL = "homePageURL"
|
static let homePageURL = "homePageURL"
|
||||||
}
|
}
|
||||||
|
|
||||||
init(dictionary: [String: String]) {
|
convenience init(dictionary: [String: String]) {
|
||||||
|
|
||||||
let name = (dictionary[Key.name] ?? dictionary[Key.editedName])!
|
let name = (dictionary[Key.name] ?? dictionary[Key.editedName])!
|
||||||
let url = dictionary[Key.url]!
|
let url = dictionary[Key.url]!
|
||||||
|
@ -10,7 +10,7 @@ import Foundation
|
|||||||
import RSCore
|
import RSCore
|
||||||
import Data
|
import Data
|
||||||
|
|
||||||
struct FeedListFolder: Hashable, DisplayNameProvider {
|
final class FeedListFolder: Hashable, DisplayNameProvider {
|
||||||
|
|
||||||
let name: String
|
let name: String
|
||||||
let feeds: Set<FeedListFeed>
|
let feeds: Set<FeedListFeed>
|
||||||
|
@ -48,7 +48,7 @@ private extension FeedListTreeControllerDelegate {
|
|||||||
|
|
||||||
func childNodesForRootNode(_ rootNode: Node) -> [Node]? {
|
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)
|
return childNodesForContainerNode(rootNode, children)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,18 +58,18 @@ private extension FeedListTreeControllerDelegate {
|
|||||||
return childNodesForContainerNode(folderNode, Array(folder.feeds))
|
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)
|
let nodes = unsortedNodes(parent: containerNode, children: children)
|
||||||
return Node.nodesSortedAlphabeticallyWithFoldersAtEnd(nodes)
|
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) }
|
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 {
|
if let feed = child as? FeedListFeed {
|
||||||
return createNode(feed: feed, parent: parent)
|
return createNode(feed: feed, parent: parent)
|
||||||
|
@ -34,16 +34,16 @@ private extension SidebarTreeControllerDelegate {
|
|||||||
// This will be expanded later to add synthetic feeds (All Unread, for instance)
|
// This will be expanded later to add synthetic feeds (All Unread, for instance)
|
||||||
// and other accounts.
|
// and other accounts.
|
||||||
|
|
||||||
return childNodesForContainerNode(rootNode, AccountManager.shared.localAccount.children as! [AnyHashable])
|
return childNodesForContainerNode(rootNode, AccountManager.shared.localAccount.children)
|
||||||
}
|
}
|
||||||
|
|
||||||
func childNodesForFolderNode(_ folderNode: Node) -> [Node]? {
|
func childNodesForFolderNode(_ folderNode: Node) -> [Node]? {
|
||||||
|
|
||||||
let folder = folderNode.representedObject as! Folder
|
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]()
|
var updatedChildNodes = [Node]()
|
||||||
|
|
||||||
@ -88,10 +88,10 @@ private extension SidebarTreeControllerDelegate {
|
|||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
func nodeInArrayRepresentingObject(_ nodes: [Node], _ representedObject: AnyHashable) -> Node? {
|
func nodeInArrayRepresentingObject(_ nodes: [Node], _ representedObject: AnyObject) -> Node? {
|
||||||
|
|
||||||
for oneNode in nodes {
|
for oneNode in nodes {
|
||||||
if oneNode.representedObject == representedObject {
|
if oneNode.representedObject === representedObject {
|
||||||
return oneNode
|
return oneNode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,10 @@ import RSCore
|
|||||||
|
|
||||||
@objc dynamic func unreadCountDidChange(_ note: Notification) {
|
@objc dynamic func unreadCountDidChange(_ note: Notification) {
|
||||||
|
|
||||||
guard let representedObject = note.object as? AnyHashable else {
|
guard let representedObject = note.object else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let _ = configureCellsForRepresentedObject(representedObject)
|
let _ = configureCellsForRepresentedObject(representedObject as AnyObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc dynamic func containerChildrenDidChange(_ note: Notification) {
|
@objc dynamic func containerChildrenDidChange(_ note: Notification) {
|
||||||
@ -176,7 +176,7 @@ private extension SidebarViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func postSidebarSelectionDidChangeNotification(_ selectedObjects: [AnyHashable]?) {
|
func postSidebarSelectionDidChangeNotification(_ selectedObjects: [AnyObject]?) {
|
||||||
|
|
||||||
let appInfo = AppInfo()
|
let appInfo = AppInfo()
|
||||||
if let objects = selectedObjects {
|
if let objects = selectedObjects {
|
||||||
@ -190,7 +190,7 @@ private extension SidebarViewController {
|
|||||||
NotificationCenter.default.post(name: .SidebarSelectionDidChange, object: self, userInfo: appInfo.userInfo)
|
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.
|
// On selection, update unread counts for folders and feeds.
|
||||||
// For feeds, actually fetch from database.
|
// For feeds, actually fetch from database.
|
||||||
@ -304,7 +304,7 @@ private extension SidebarViewController {
|
|||||||
return cells
|
return cells
|
||||||
}
|
}
|
||||||
|
|
||||||
func cellsForRepresentedObject(_ representedObject: AnyHashable) -> [SidebarCell] {
|
func cellsForRepresentedObject(_ representedObject: AnyObject) -> [SidebarCell] {
|
||||||
|
|
||||||
let availableCells = availableSidebarCells()
|
let availableCells = availableSidebarCells()
|
||||||
return availableCells.filter{ (oneSidebarCell) -> Bool in
|
return availableCells.filter{ (oneSidebarCell) -> Bool in
|
||||||
@ -312,11 +312,11 @@ private extension SidebarViewController {
|
|||||||
guard let oneNode = oneSidebarCell.objectValue as? Node else {
|
guard let oneNode = oneSidebarCell.objectValue as? Node else {
|
||||||
return false
|
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.
|
//Return true if any cells were configured.
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ private extension SidebarViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
func revealAndSelectRepresentedObject(_ representedObject: AnyHashable) -> Bool {
|
func revealAndSelectRepresentedObject(_ representedObject: AnyObject) -> Bool {
|
||||||
|
|
||||||
return outlineView.revealAndSelectRepresentedObject(representedObject, treeController)
|
return outlineView.revealAndSelectRepresentedObject(representedObject, treeController)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class TimelineViewController: NSViewController, KeyboardDelegate, UndoableComman
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var representedObjects: [AnyHashable]? {
|
private var representedObjects: [AnyObject]? {
|
||||||
didSet {
|
didSet {
|
||||||
if !representedObjectArraysAreEqual(oldValue, representedObjects) {
|
if !representedObjectArraysAreEqual(oldValue, representedObjects) {
|
||||||
fetchArticles()
|
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 {
|
if objects1 == nil && objects2 == nil {
|
||||||
return true
|
return true
|
||||||
@ -463,7 +463,7 @@ private extension TimelineViewController {
|
|||||||
|
|
||||||
var ix = 0
|
var ix = 0
|
||||||
for oneObject in objects1 {
|
for oneObject in objects1 {
|
||||||
if oneObject != objects2[ix] {
|
if oneObject !== objects2[ix] {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
ix += 1
|
ix += 1
|
||||||
|
@ -44,7 +44,7 @@ public extension NSOutlineView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@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 {
|
guard let nodePath = NodePath(representedObject: representedObject, treeController: treeController) else {
|
||||||
return false
|
return false
|
||||||
|
@ -11,7 +11,7 @@ import Foundation
|
|||||||
public final class Node: Equatable {
|
public final class Node: Equatable {
|
||||||
|
|
||||||
public weak var parent: Node?
|
public weak var parent: Node?
|
||||||
public let representedObject: AnyHashable
|
public let representedObject: AnyObject
|
||||||
public var canHaveChildNodes = false
|
public var canHaveChildNodes = false
|
||||||
public var isGroupItem = false
|
public var isGroupItem = false
|
||||||
public var childNodes: [Node]?
|
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.representedObject = representedObject
|
||||||
self.parent = parent
|
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 {
|
guard let childNodes = childNodes else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for oneNode in childNodes {
|
for oneNode in childNodes {
|
||||||
if oneNode.representedObject == obj {
|
if oneNode.representedObject === obj {
|
||||||
return oneNode
|
return oneNode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public struct NodePath {
|
|||||||
self.components = tempArray.reversed()
|
self.components = tempArray.reversed()
|
||||||
}
|
}
|
||||||
|
|
||||||
public init?(representedObject: AnyHashable, treeController: TreeController) {
|
public init?(representedObject: AnyObject, treeController: TreeController) {
|
||||||
|
|
||||||
if let node = treeController.nodeInTreeRepresentingObject(representedObject) {
|
if let node = treeController.nodeInTreeRepresentingObject(representedObject) {
|
||||||
self.init(node: node)
|
self.init(node: node)
|
||||||
|
@ -10,12 +10,6 @@ import Foundation
|
|||||||
|
|
||||||
// Handy to use as the represented object for a root node. Not required to use it, though.
|
// 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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,11 @@ public final class TreeController {
|
|||||||
visitNode(rootNode, visitBlock)
|
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 {
|
for oneNode in nodes {
|
||||||
|
|
||||||
if oneNode.representedObject == representedObject {
|
if oneNode.representedObject === representedObject {
|
||||||
return oneNode
|
return oneNode
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public final class TreeController {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
public func nodeInTreeRepresentingObject(_ representedObject: AnyHashable) -> Node? {
|
public func nodeInTreeRepresentingObject(_ representedObject: AnyObject) -> Node? {
|
||||||
|
|
||||||
return nodeInArrayRepresentingObject(nodes: [rootNode], representedObject: representedObject, recurse: true)
|
return nodeInArrayRepresentingObject(nodes: [rootNode], representedObject: representedObject, recurse: true)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user