diff --git a/IMGTreeTableView.xcodeproj/project.pbxproj b/IMGTreeTableView.xcodeproj/project.pbxproj
index 72d4413..c59a13d 100644
--- a/IMGTreeTableView.xcodeproj/project.pbxproj
+++ b/IMGTreeTableView.xcodeproj/project.pbxproj
@@ -197,7 +197,9 @@
24C3DE7E1AC4B617008E3087 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0620;
+ LastSwiftMigration = 0700;
+ LastSwiftUpdateCheck = 0700;
+ LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Geoff MacDonald";
TargetAttributes = {
24386E111B389007009DA1A6 = {
@@ -310,6 +312,7 @@
INFOPLIST_FILE = "$(SRCROOT)/IMGTreeTableViewDemo/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = "imgur.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -323,6 +326,7 @@
INFOPLIST_FILE = "$(SRCROOT)/IMGTreeTableViewDemo/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = "imgur.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
@@ -346,6 +350,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = "Imgur.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -370,6 +375,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = "Imgur.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -398,6 +404,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
diff --git a/IMGTreeTableView/IMGTree.swift b/IMGTreeTableView/IMGTree.swift
index 70970af..5a28bc6 100644
--- a/IMGTreeTableView/IMGTree.swift
+++ b/IMGTreeTableView/IMGTree.swift
@@ -50,7 +50,7 @@ public class IMGTree: NSObject, NSCoding, NSCopying {
// go through each top level object creating the resulting node subtree for each one recursively with the process(:::) method
for rootObject in rootArray {
- let rootNode = nodeClass(parentNode: tree.rootNode)
+ let rootNode = nodeClass.init(parentNode: tree.rootNode)
constructorDelegate.configureNode(rootNode, modelObject: rootObject)
if let childObjects = constructorDelegate.childrenForNodeObject(rootObject) {
rootNode.children = IMGTree.process(tree.rootNode, childObjects: childObjects, tree: tree, constructorDelegate: constructorDelegate) as! [IMGTreeNode]
@@ -69,7 +69,7 @@ public class IMGTree: NSObject, NSCoding, NSCopying {
let nodeClass = constructorDelegate.classForNode()
var childNodes: [IMGTreeNode] = []
for childObject in childObjects {
- let childNode = nodeClass(parentNode: parentNode)
+ let childNode = nodeClass.init(parentNode: parentNode)
constructorDelegate.configureNode(childNode, modelObject: childObject)
if let childObjects = constructorDelegate.childrenForNodeObject(childObject) {
childNode.children = IMGTree.process(tree.rootNode, childObjects: childObjects, tree: tree, constructorDelegate: constructorDelegate) as! [IMGTreeNode]
@@ -88,7 +88,7 @@ public class IMGTree: NSObject, NSCoding, NSCopying {
//MARK: NSCoding
- required convenience public init(coder aDecoder: NSCoder) {
+ required convenience public init?(coder aDecoder: NSCoder) {
self.init()
//TODO: implementation
}
@@ -147,7 +147,7 @@ public class IMGTreeNode: NSObject, NSCoding, NSCopying {
*/
public var children: [IMGTreeNode] = [] {
didSet {
- children = children.map({ (var node: IMGTreeNode) -> IMGTreeNode in
+ children = children.map({ (node: IMGTreeNode) -> IMGTreeNode in
node.parentNode = self
node.controller = self.controller
return node
@@ -317,7 +317,7 @@ public class IMGTreeNode: NSObject, NSCoding, NSCopying {
//MARK: NSCoding
- public required init(coder aDecoder: NSCoder) {
+ public required init?(coder aDecoder: NSCoder) {
fatalError("")
}
@@ -343,7 +343,7 @@ public class IMGTreeNode: NSObject, NSCoding, NSCopying {
Remove a child.
*/
func removeChild(child: IMGTreeNode) {
- if let targetIndex = find(children, child) {
+ if let targetIndex = children.indexOf(child) {
children.removeAtIndex(targetIndex)
}
}
@@ -373,23 +373,23 @@ public class IMGTreeNode: NSObject, NSCoding, NSCopying {
Finds the location, if any, of the node with this instances children regardless of visibility
*/
func indexForNode(node: IMGTreeNode) -> Int? {
- var traversal = infixTraversal(visible: false)
- return find(traversal, node)
+ let traversal = infixTraversal(false)
+ return traversal.indexOf(node)
}
/**
Finds the location, if any, of the node with this instances visible children
*/
func visibleIndexForNode(node: IMGTreeNode) -> Int? {
- var traversal = infixTraversal()
- return find(traversal, node)
+ let traversal = infixTraversal()
+ return traversal.indexOf(node)
}
/**
Finds the number of visible child nodes
*/
func traversalCount() -> Int {
- return infixTraversal(visible: false).count ?? 0
+ return infixTraversal(false).count ?? 0
}
/**
@@ -421,7 +421,7 @@ public class IMGTreeNode: NSObject, NSCoding, NSCopying {
Does there exist a user selection within any of this nodes subtree
*/
func isSelectionNodeInTraversal(visible: Bool? = true) -> Bool {
- let traversal = infixTraversal(visible: visible!)
+ let traversal = infixTraversal(visible!)
for node in traversal {
if node.isKindOfClass(IMGTreeSelectionNode) {
return true
@@ -444,11 +444,11 @@ public class IMGTreeNode: NSObject, NSCoding, NSCopying {
*/
func infixTraversal(visible: Bool = true) -> [IMGTreeNode] {
- var traversal = { (childNodes: [IMGTreeNode]) -> [IMGTreeNode] in
+ let traversal = { (childNodes: [IMGTreeNode]) -> [IMGTreeNode] in
var traversal: [IMGTreeNode] = []
for node in childNodes {
traversal.append(node)
- traversal.extend(node.infixTraversal(visible: visible))
+ traversal.appendContentsOf(node.infixTraversal(visible))
}
if visible && self.rootNode == self && !self.preventCacheUse {
self.visibleInfixCache = traversal
@@ -457,7 +457,7 @@ public class IMGTreeNode: NSObject, NSCoding, NSCopying {
}
if visible {
- var childNodes = children.filter({ (node: IMGTreeNode) -> Bool in
+ let childNodes = children.filter({ (node: IMGTreeNode) -> Bool in
return node.isVisible
})
return traversal(childNodes)
@@ -516,7 +516,7 @@ public class IMGTreeNode: NSObject, NSCoding, NSCopying {
//MARK: NSCopying
public func copyWithZone(zone: NSZone) -> AnyObject {
- let nodeCopy = self.dynamicType(parentNode: parentNode!)
+ let nodeCopy = self.dynamicType.init(parentNode: parentNode!)
nodeCopy.controller = controller
nodeCopy.isVisible = isVisible
nodeCopy.parentNode = parentNode
@@ -544,7 +544,7 @@ public class IMGTreeActionNode : IMGTreeNode {
/**
Class for nodes that represent collapsed sections
*/
-public class IMGTreeCollapsedSectionNode : IMGTreeNode, NSCopying {
+public class IMGTreeCollapsedSectionNode : IMGTreeNode {
/**
The anchor or top level node this collapsed node is ancestor to
@@ -572,8 +572,8 @@ public class IMGTreeCollapsedSectionNode : IMGTreeNode, NSCopying {
var indicesForContainingNodes: [NSIndexPath] {
var rowsToHide: [NSIndexPath] = []
- rowsToHide.extend(originatingNode.visibleIndicesForTraversal())
- originatingNode.children.map({ (var child: IMGTreeNode) -> IMGTreeNode in
+ rowsToHide.appendContentsOf(originatingNode.visibleIndicesForTraversal())
+ originatingNode.children.map({ (child: IMGTreeNode) -> IMGTreeNode in
child.isVisible = false
return child
})
@@ -590,8 +590,8 @@ public class IMGTreeCollapsedSectionNode : IMGTreeNode, NSCopying {
var indicesToBeHidden: NSIndexSet {
let rowsDeleted = NSMutableIndexSet()
- var firstRemovalIndex = anchorNode.visibleTraversalIndex()! + 1
- var removeRange = anchorNode.visibleTraversalCount
+ let firstRemovalIndex = anchorNode.visibleTraversalIndex()! + 1
+ let removeRange = anchorNode.visibleTraversalCount
rowsDeleted.addIndexesInRange(NSMakeRange(firstRemovalIndex, removeRange))
@@ -599,13 +599,13 @@ public class IMGTreeCollapsedSectionNode : IMGTreeNode, NSCopying {
}
var nodesToBeHidden: [IMGTreeNode] {
- var nodes = anchorNode.infixTraversal()
+ let nodes = anchorNode.infixTraversal()
return nodes
}
// MARK: Initializers
- public required init(coder aDecoder: NSCoder) {
+ public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@@ -648,7 +648,7 @@ public class IMGTreeCollapsedSectionNode : IMGTreeNode, NSCopying {
//MARK: NSCopying
public override func copyWithZone(zone: NSZone) -> AnyObject {
- var nodeCopy = self.dynamicType(parentNode: originatingNode)
+ let nodeCopy = self.dynamicType.init(parentNode: originatingNode)
nodeCopy.isVisible = isVisible
nodeCopy.children = children.map({ (childNode: IMGTreeNode) -> IMGTreeNode in
return childNode.copy() as! IMGTreeNode
@@ -661,4 +661,4 @@ public class IMGTreeCollapsedSectionNode : IMGTreeNode, NSCopying {
public override var description : String {
return "Collapsed Node: \(rootNode.visibleIndexForNode(self)!) \n"
}
-}
\ No newline at end of file
+}
diff --git a/IMGTreeTableView/IMGTreeTableController.swift b/IMGTreeTableView/IMGTreeTableController.swift
index b347170..c5b2edb 100644
--- a/IMGTreeTableView/IMGTreeTableController.swift
+++ b/IMGTreeTableView/IMGTreeTableController.swift
@@ -104,7 +104,7 @@ public class IMGTreeTableController: NSObject, UITableViewDataSource{
func setNodeChildrenVisiblility(parentNode: IMGTreeNode, visibility: Bool) {
if !visibility {
- for child in reverse(parentNode.children) {
+ for child in Array(parentNode.children.reverse()) {
child.isVisible = visibility
}
} else {
@@ -158,7 +158,7 @@ public class IMGTreeTableController: NSObject, UITableViewDataSource{
}
public func hideActionNode () {
- if let currentActionNode = actionNode {
+ if let _ = actionNode {
transactionInProgress = true
//hide previous selection node
actionNode?.removeFromParent()
@@ -168,7 +168,7 @@ public class IMGTreeTableController: NSObject, UITableViewDataSource{
}
public func nodePassingTest(test: (node: IMGTreeNode) -> Bool) -> IMGTreeNode? {
- if let traversal = tree?.rootNode.infixTraversal(visible: false) {
+ if let traversal = tree?.rootNode.infixTraversal(false) {
for node in traversal {
if test(node: node) {
return node
@@ -185,13 +185,13 @@ public class IMGTreeTableController: NSObject, UITableViewDataSource{
var currentNode = node
var selectedNodes: [IMGTreeNode] = []
while currentNode.parentNode != nil {
- var selectedNode = currentNode.parentNode!
+ let selectedNode = currentNode.parentNode!
selectedNodes.append(selectedNode)
currentNode = selectedNode
}
disableAnimation = true
- for selectedNode in reverse(selectedNodes) {
+ for selectedNode in Array(selectedNodes.reverse()) {
didSelectNode(selectedNode)
}
disableAnimation = false
@@ -270,7 +270,7 @@ public class IMGTreeTableController: NSObject, UITableViewDataSource{
//delete rows collapsed section will hide
let nodesToHide = collapsedNode.nodesToBeHidden
let nodeIndicesToHide = collapsedNode.indicesToBeHidden
- for internalNode in reverse(nodesToHide) {
+ for internalNode in Array(nodesToHide.reverse()) {
internalNode.isVisible = false
}
@@ -406,23 +406,23 @@ public class IMGTreeTableController: NSObject, UITableViewDataSource{
tableView.beginUpdates()
}
- var addedIndices: [AnyObject] = []
+ var addedIndices: [NSIndexPath] = []
for node in insertedNodes {
if let rowIndex = node.visibleTraversalIndex() {
let indexPath = NSIndexPath(forRow: rowIndex, inSection: 0)
addedIndices.append(indexPath)
}
- addedIndices.extend(node.visibleIndicesForTraversal() as [AnyObject])
+ addedIndices.appendContentsOf(node.visibleIndicesForTraversal() as [NSIndexPath])
}
- var deletedIndices: [AnyObject] = []
+ var deletedIndices: [NSIndexPath] = []
for node in deletedNodes {
if let rowIndex = node.previousVisibleIndex {
let indexPath = NSIndexPath(forRow: rowIndex, inSection: 0)
deletedIndices.append(indexPath)
}
- deletedIndices.extend(node.previousVisibleChildren! as [AnyObject])
+ deletedIndices.appendContentsOf(node.previousVisibleChildren! as [NSIndexPath])
}
if !disableAnimation {
diff --git a/IMGTreeTableView/Info.plist b/IMGTreeTableView/Info.plist
index ff6a805..d3de8ee 100644
--- a/IMGTreeTableView/Info.plist
+++ b/IMGTreeTableView/Info.plist
@@ -7,7 +7,7 @@
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
- Imgur.$(PRODUCT_NAME:rfc1034identifier)
+ $(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
diff --git a/IMGTreeTableViewDemo/IMGSampleTreeConstructor.swift b/IMGTreeTableViewDemo/IMGSampleTreeConstructor.swift
index 1d02b16..4fd3cf8 100644
--- a/IMGTreeTableViewDemo/IMGSampleTreeConstructor.swift
+++ b/IMGTreeTableViewDemo/IMGSampleTreeConstructor.swift
@@ -9,7 +9,7 @@
import UIKit
import IMGTreeTableView
-class IMGCommentNode: IMGTreeNode, NSCopying {
+class IMGCommentNode: IMGTreeNode {
var comment: String?
override var description : String {
@@ -17,7 +17,7 @@ class IMGCommentNode: IMGTreeNode, NSCopying {
}
override func copyWithZone(zone: NSZone) -> AnyObject {
- var copy = super.copyWithZone(zone) as! IMGCommentNode
+ let copy = super.copyWithZone(zone) as! IMGCommentNode
copy.comment = comment
return copy
}
diff --git a/IMGTreeTableViewDemo/Info.plist b/IMGTreeTableViewDemo/Info.plist
index 24b80ba..fab4b93 100644
--- a/IMGTreeTableViewDemo/Info.plist
+++ b/IMGTreeTableViewDemo/Info.plist
@@ -7,7 +7,7 @@
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
- imgur.$(PRODUCT_NAME:rfc1034identifier)
+ $(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
diff --git a/IMGTreeTableViewDemo/ViewController.swift b/IMGTreeTableViewDemo/ViewController.swift
index d1e69bd..b1104e8 100644
--- a/IMGTreeTableViewDemo/ViewController.swift
+++ b/IMGTreeTableViewDemo/ViewController.swift
@@ -37,7 +37,7 @@ class ViewController: UIViewController, IMGTreeTableControllerDelegate, UITableV
// MARK: IMGTreeTableControllerDelegate
func cell(node: IMGTreeNode, indexPath: NSIndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell
+ let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)
cell.accessoryType = .None
switch node {
case let commentNode as IMGCommentNode: