From ea25d675acdf4209bf5092e086c6c90dc7340e5b Mon Sep 17 00:00:00 2001 From: Daniel Dahan Date: Fri, 1 Apr 2016 17:08:53 -0400 Subject: [PATCH] removed c-style code --- Graph.podspec | 2 +- Sources/GraphSearch.swift | 21 +++++++++++++++------ Sources/GraphWatch.swift | 2 +- Sources/Info.plist | 2 +- Tests/ActionStressTests.swift | 21 ++++++++++++++------- Tests/EntityStressTests.swift | 21 ++++++++++++++------- Tests/RelationshipStressTests.swift | 21 ++++++++++++++------- 7 files changed, 60 insertions(+), 30 deletions(-) diff --git a/Graph.podspec b/Graph.podspec index 76cd124e..852aff62 100755 --- a/Graph.podspec +++ b/Graph.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Graph' - s.version = '1.0.10' + s.version = '1.0.11' s.license = 'BSD' s.summary = 'An elegant data-driven framework for CoreData in Swift.' s.homepage = 'http://cosmicmind.io' diff --git a/Sources/GraphSearch.swift b/Sources/GraphSearch.swift index 09365a19..68883343 100644 --- a/Sources/GraphSearch.swift +++ b/Sources/GraphSearch.swift @@ -60,20 +60,23 @@ public extension Graph { if toFilter { var seen: Dictionary = Dictionary() - var i: Int = nodes.count - while 0 <= --i { + var i: Int = nodes.count - 1 + while 0 <= i { if let v: ManagedEntity = nodes[i] as? ManagedEntity { if nil == seen.updateValue(true, forKey: v.id) { nodes[i] = Entity(object: v) + i -= 1 continue } } else if let v: ManagedEntity = Graph.context!.objectWithID(nodes[i]["node"]! as! NSManagedObjectID) as? ManagedEntity { if nil == seen.updateValue(true, forKey: v.id) { nodes[i] = Entity(object: v) + i -= 1 continue } } nodes.removeAtIndex(i) + i -= 1 } return nodes as! Array } else { @@ -115,20 +118,23 @@ public extension Graph { if toFilter { var seen: Dictionary = Dictionary() - var i: Int = nodes.count - while 0 <= --i { + var i: Int = nodes.count - 1 + while 0 <= i { if let v: ManagedRelationship = nodes[i] as? ManagedRelationship { if nil == seen.updateValue(true, forKey: v.id) { nodes[i] = Relationship(object: v) + i -= 1 continue } } else if let v: ManagedRelationship = Graph.context!.objectWithID(nodes[i]["node"]! as! NSManagedObjectID) as? ManagedRelationship { if nil == seen.updateValue(true, forKey: v.id) { nodes[i] = Relationship(object: v) + i -= 1 continue } } nodes.removeAtIndex(i) + i -= 1 } return nodes as! Array } else { @@ -170,20 +176,23 @@ public extension Graph { if toFilter { var seen: Dictionary = Dictionary() - var i: Int = nodes.count - while 0 <= --i { + var i: Int = nodes.count - 1 + while 0 <= i { if let v: ManagedAction = nodes[i] as? ManagedAction { if nil == seen.updateValue(true, forKey: v.id) { nodes[i] = Action(object: v) + i -= 1 continue } } else if let v: ManagedAction = Graph.context!.objectWithID(nodes[i]["node"]! as! NSManagedObjectID) as? ManagedAction { if nil == seen.updateValue(true, forKey: v.id) { nodes[i] = Action(object: v) + i -= 1 continue } } nodes.removeAtIndex(i) + i -= 1 } return nodes as! Array } else { diff --git a/Sources/GraphWatch.swift b/Sources/GraphWatch.swift index d795d872..14d04ab7 100644 --- a/Sources/GraphWatch.swift +++ b/Sources/GraphWatch.swift @@ -182,7 +182,7 @@ public extension Graph { internal func prepareForObservation() { NSNotificationCenter.defaultCenter().removeObserver(self) NSNotificationCenter.defaultCenter().removeObserver(self, name: NSManagedObjectContextDidSaveNotification, object: Graph.context) - NSNotificationCenter.defaultCenter().addObserver(self, selector: "managedObjectContextDidSave:", name: NSManagedObjectContextDidSaveNotification, object: Graph.context) + NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(managedObjectContextDidSave(_:)), name: NSManagedObjectContextDidSaveNotification, object: Graph.context) } // diff --git a/Sources/Info.plist b/Sources/Info.plist index b174d9c3..571c340f 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.10 + 1.0.11 CFBundleSignature ???? CFBundleVersion diff --git a/Tests/ActionStressTests.swift b/Tests/ActionStressTests.swift index 9a6c9f30..06796f13 100644 --- a/Tests/ActionStressTests.swift +++ b/Tests/ActionStressTests.swift @@ -138,7 +138,8 @@ class ActionStressTests : XCTestCase, GraphDelegate { XCTAssertTrue(5 == action.subjects.count) XCTAssertTrue(5 == action.objects.count) - if 100 == ++insertActionCount { + insertActionCount += 1 + if 100 == insertActionCount { insertExpectation?.fulfill() } } @@ -151,7 +152,8 @@ class ActionStressTests : XCTestCase, GraphDelegate { XCTAssertEqual(5, action.subjects.count) XCTAssertEqual(5, action.objects.count) - if 100 == ++insertPropertyCount { + insertPropertyCount += 1 + if 100 == insertPropertyCount { insertPropertyExpectation?.fulfill() } } @@ -162,7 +164,8 @@ class ActionStressTests : XCTestCase, GraphDelegate { XCTAssertEqual(5, action.subjects.count) XCTAssertEqual(5, action.objects.count) - if 100 == ++insertGroupCount { + insertGroupCount += 1 + if 100 == insertGroupCount { insertGroupExpectation?.fulfill() } } @@ -175,7 +178,8 @@ class ActionStressTests : XCTestCase, GraphDelegate { XCTAssertEqual(5, action.subjects.count) XCTAssertEqual(5, action.objects.count) - if 100 == ++updatePropertyCount { + updatePropertyCount += 1 + if 100 == updatePropertyCount { updatePropertyExpectation?.fulfill() } } @@ -185,7 +189,8 @@ class ActionStressTests : XCTestCase, GraphDelegate { XCTAssertEqual(5, action.subjects.count) XCTAssertEqual(5, action.objects.count) - if 0 == --insertActionCount { + insertActionCount -= 1 + if 0 == insertActionCount { deleteExpectation?.fulfill() } } @@ -197,7 +202,8 @@ class ActionStressTests : XCTestCase, GraphDelegate { XCTAssertEqual(5, action.subjects.count) XCTAssertEqual(5, action.objects.count) - if 0 == --insertPropertyCount { + insertPropertyCount -= 1 + if 0 == insertPropertyCount { deletePropertyExpectation?.fulfill() } } @@ -208,7 +214,8 @@ class ActionStressTests : XCTestCase, GraphDelegate { XCTAssertEqual(5, action.subjects.count) XCTAssertEqual(5, action.objects.count) - if 0 == --insertGroupCount { + insertGroupCount -= 1 + if 0 == insertGroupCount { deleteGroupExpectation?.fulfill() } } diff --git a/Tests/EntityStressTests.swift b/Tests/EntityStressTests.swift index e2b01c06..c371fdd8 100644 --- a/Tests/EntityStressTests.swift +++ b/Tests/EntityStressTests.swift @@ -117,7 +117,8 @@ class EntityStressTests : XCTestCase, GraphDelegate { XCTAssertTrue(entity["P"] as? String == "A") XCTAssertTrue(entity.hasGroup("G")) - if 1000 == ++insertEntityCount { + insertEntityCount += 1 + if 1000 == insertEntityCount { insertExpectation?.fulfill() } } @@ -128,7 +129,8 @@ class EntityStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("A" == value as? String) XCTAssertTrue(entity[property] as? String == value as? String) - if 1000 == ++insertPropertyCount { + insertPropertyCount += 1 + if 1000 == insertPropertyCount { insertPropertyExpectation?.fulfill() } } @@ -137,7 +139,8 @@ class EntityStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("T" == entity.type) XCTAssertTrue("G" == group) - if 1000 == ++insertGroupCount { + insertGroupCount += 1 + if 1000 == insertGroupCount { insertGroupExpectation?.fulfill() } } @@ -148,7 +151,8 @@ class EntityStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("B" == value as? String) XCTAssertTrue(entity[property] as? String == value as? String) - if 1000 == ++updatePropertyCount { + updatePropertyCount += 1 + if 1000 == updatePropertyCount { updatePropertyExpectation?.fulfill() } } @@ -156,7 +160,8 @@ class EntityStressTests : XCTestCase, GraphDelegate { func graphDidDeleteEntity(graph: Graph, entity: Entity) { XCTAssertTrue("T" == entity.type) - if 0 == --insertEntityCount { + insertEntityCount -= 1 + if 0 == insertEntityCount { deleteExpectation?.fulfill() } } @@ -166,7 +171,8 @@ class EntityStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("P" == property) XCTAssertTrue("B" == value as? String) - if 0 == --insertPropertyCount { + insertPropertyCount -= 1 + if 0 == insertPropertyCount { deletePropertyExpectation?.fulfill() } } @@ -175,7 +181,8 @@ class EntityStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("T" == entity.type) XCTAssertTrue("G" == group) - if 0 == --insertGroupCount { + insertGroupCount -= 1 + if 0 == insertGroupCount { deleteGroupExpectation?.fulfill() } } diff --git a/Tests/RelationshipStressTests.swift b/Tests/RelationshipStressTests.swift index 75e1185b..16ba871b 100644 --- a/Tests/RelationshipStressTests.swift +++ b/Tests/RelationshipStressTests.swift @@ -123,7 +123,8 @@ class RelationshipStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("S" == relationship.subject?.type) XCTAssertTrue("O" == relationship.object?.type) - if 1000 == ++insertRelationshipCount { + insertRelationshipCount += 1 + if 1000 == insertRelationshipCount { insertExpectation?.fulfill() } } @@ -136,7 +137,8 @@ class RelationshipStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("S" == relationship.subject?.type) XCTAssertTrue("O" == relationship.object?.type) - if 1000 == ++insertPropertyCount { + insertPropertyCount += 1 + if 1000 == insertPropertyCount { insertPropertyExpectation?.fulfill() } } @@ -145,7 +147,8 @@ class RelationshipStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("T" == relationship.type) XCTAssertTrue("G" == group) - if 1000 == ++insertGroupCount { + insertGroupCount += 1 + if 1000 == insertGroupCount { insertGroupExpectation?.fulfill() } } @@ -158,7 +161,8 @@ class RelationshipStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("S" == relationship.subject?.type) XCTAssertTrue("O" == relationship.object?.type) - if 1000 == ++updatePropertyCount { + updatePropertyCount += 1 + if 1000 == updatePropertyCount { updatePropertyExpectation?.fulfill() } } @@ -168,7 +172,8 @@ class RelationshipStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("S" == relationship.subject?.type) XCTAssertTrue("O" == relationship.object?.type) - if 0 == --insertRelationshipCount { + insertRelationshipCount -= 1 + if 0 == insertRelationshipCount { deleteExpectation?.fulfill() } } @@ -180,7 +185,8 @@ class RelationshipStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("S" == relationship.subject?.type) XCTAssertTrue("O" == relationship.object?.type) - if 0 == --insertPropertyCount { + insertPropertyCount -= 1 + if 0 == insertPropertyCount { deletePropertyExpectation?.fulfill() } } @@ -191,7 +197,8 @@ class RelationshipStressTests : XCTestCase, GraphDelegate { XCTAssertTrue("S" == relationship.subject?.type) XCTAssertTrue("O" == relationship.object?.type) - if 0 == --insertGroupCount { + insertGroupCount -= 1 + if 0 == insertGroupCount { deleteGroupExpectation?.fulfill() } }