Skip to content

Commit a9aaf23

Browse files
author
Daniel Dahan
committed
development: xcode beta 8 revisions
1 parent 5435c8c commit a9aaf23

31 files changed

+332
-278
lines changed

Sources/Action.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public class Action: NSObject, NodeType {
8080
/**
8181
Access properties using the subscript operator.
8282
- Parameter name: A property name value.
83-
- Returns: The optional AnyObject value.
83+
- Returns: The optional Any value.
8484
*/
85-
public subscript(name: String) -> AnyObject? {
85+
public subscript(name: String) -> Any? {
8686
get {
8787
return managedNode[name]
8888
}
@@ -92,7 +92,7 @@ public class Action: NSObject, NodeType {
9292
}
9393

9494
/// A reference to the properties Dictionary.
95-
public var properties: [String: AnyObject] {
95+
public var properties: [String: Any] {
9696
return managedNode.properties
9797
}
9898

@@ -182,7 +182,7 @@ public class Action: NSObject, NodeType {
182182
- Returns: A boolean of the result, true if equal, false
183183
otherwise.
184184
*/
185-
public override func isEqual(_ object: AnyObject?) -> Bool {
185+
public override func isEqual(_ object: Any?) -> Bool {
186186
return id == (object as? Action)?.id
187187
}
188188

Sources/Context.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ extension Graph {
121121
guard let s = self else {
122122
return
123123
}
124-
s.completion?(supported: supported, error: supported ? nil : GraphError(message: "[Graph Error: iCloud is not supported.]"))
124+
s.completion?(supported, supported ? nil : GraphError(message: "[Graph Error: iCloud is not supported.]"))
125125
(s.delegate as? GraphCloudDelegate)?.graphDidPrepareCloudStorage?(graph: s)
126126
}
127127
}

Sources/Coordinator.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal struct Coordinator {
5151
- Parameter options: Additional options.
5252
- Returns: An instance of NSPersistentStoreCoordinator.
5353
*/
54-
static func create(type: String, location: URL, options: [NSObject: AnyObject]? = nil) -> NSPersistentStoreCoordinator {
54+
static func create(type: String, location: URL, options: [NSObject: Any]? = nil) -> NSPersistentStoreCoordinator {
5555
var coordinator: NSPersistentStoreCoordinator?
5656
File.createDirectoryAtPath(location, withIntermediateDirectories: true, attributes: nil) { (success: Bool, error: Error?) in
5757
if let e = error {
@@ -75,10 +75,10 @@ extension Graph {
7575
return
7676
}
7777

78-
var options: [NSObject: AnyObject]?
78+
var options: [AnyHashable: Any]?
7979

8080
if supported {
81-
options = [NSObject: AnyObject]()
81+
options = [AnyHashable: Any]()
8282
options?[NSPersistentStoreUbiquitousContentNameKey] = name
8383
}
8484

@@ -88,7 +88,7 @@ extension Graph {
8888
try moc.persistentStoreCoordinator?.addPersistentStore(ofType: type, configurationName: nil, at: location, options: options)
8989
location = moc.persistentStoreCoordinator!.persistentStores.first!.url!
9090
if !supported {
91-
completion?(supported: false, error: GraphError(message: "[Graph Error: iCloud is not supported.]"))
91+
completion?(false, GraphError(message: "[Graph Error: iCloud is not supported.]"))
9292
}
9393
} catch let e as NSError {
9494
fatalError("[Graph Error: \(e.localizedDescription)]")
@@ -141,7 +141,7 @@ extension Graph {
141141

142142
internal func persistentStoreDidChange(_ notification: Notification) {
143143
GraphContextRegistry.added[self.route] = true
144-
self.completion?(supported: true, error: nil)
144+
self.completion?(true, nil)
145145
(self.delegate as? GraphCloudDelegate)?.graphDidPrepareCloudStorage?(graph: self)
146146
}
147147

Sources/Entity.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public class Entity: NSObject, NodeType {
8181
/**
8282
Access properties using the subscript operator.
8383
- Parameter name: A property name value.
84-
- Returns: The optional AnyObject value.
84+
- Returns: The optional Any value.
8585
*/
86-
public subscript(name: String) -> AnyObject? {
86+
public subscript(name: String) -> Any? {
8787
get {
8888
return managedNode[name]
8989
}
@@ -93,7 +93,7 @@ public class Entity: NSObject, NodeType {
9393
}
9494

9595
/// A reference to the properties Dictionary.
96-
public var properties: [String: AnyObject] {
96+
public var properties: [String: Any] {
9797
return managedNode.properties
9898
}
9999

@@ -222,7 +222,7 @@ public class Entity: NSObject, NodeType {
222222
- Returns: A boolean of the result, true if equal, false
223223
otherwise.
224224
*/
225-
public override func isEqual(_ object: AnyObject?) -> Bool {
225+
public override func isEqual(_ object: Any?) -> Bool {
226226
return id == (object as? Entity)?.id
227227
}
228228

Sources/File.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,12 @@ public struct File {
201201
- Parameter completion: An optional completion block when the operation
202202
is done.
203203
*/
204-
public static func removeItemAtPath(_ path: URL, completion: ((removed: Bool?, error: Error?) -> Void)? = nil) {
204+
public static func removeItemAtPath(_ path: URL, completion: ((Bool?, Error?) -> Void)? = nil) {
205205
do {
206206
try FileManager.default.removeItem(atPath: path.path)
207-
completion?(removed: true, error: nil)
207+
completion?(true, nil)
208208
} catch let e as NSError {
209-
completion?(removed: nil, error: e)
209+
completion?(nil, e)
210210
}
211211
}
212212

@@ -218,12 +218,12 @@ public struct File {
218218
- Parameter completion: An optional completion block when the operation
219219
is done.
220220
*/
221-
public static func createDirectoryAtPath(_ path: URL, withIntermediateDirectories createIntermediates: Bool, attributes: [String: AnyObject]?, completion: ((success: Bool, error: Error?) -> Void)? = nil) {
221+
public static func createDirectoryAtPath(_ path: URL, withIntermediateDirectories createIntermediates: Bool, attributes: [String: Any]?, completion: ((Bool, Error?) -> Void)? = nil) {
222222
do {
223223
try FileManager.default.createDirectory(atPath: path.path, withIntermediateDirectories: createIntermediates, attributes: attributes)
224-
completion?(success: true, error: nil)
224+
completion?(true, nil)
225225
} catch let e as NSError {
226-
completion?(success: false, error: e)
226+
completion?(false, e)
227227
}
228228
}
229229

@@ -233,12 +233,12 @@ public struct File {
233233
- Parameter completion: An optional completion block when the operation
234234
is done.
235235
*/
236-
public static func removeDirectoryAtPath(_ path: URL, completion: ((success: Bool, error: Error?) -> Void)? = nil) {
236+
public static func removeDirectoryAtPath(_ path: URL, completion: ((Bool, Error?) -> Void)? = nil) {
237237
do {
238238
try FileManager.default.removeItem(at: path)
239-
completion?(success: true, error: nil)
239+
completion?(true, nil)
240240
} catch let e as NSError {
241-
completion?(success: false, error: e)
241+
completion?(false, e)
242242
}
243243
}
244244

@@ -249,12 +249,12 @@ public struct File {
249249
- Parameter completion: An optional completion block when the operation
250250
is done.
251251
*/
252-
public static func contentsOfDirectoryAtPath(_ path: URL, shouldSkipHiddenFiles skip: Bool = false, completion: ((contents: [URL]?, error: Error?) -> Void)) {
252+
public static func contentsOfDirectoryAtPath(_ path: URL, shouldSkipHiddenFiles skip: Bool = false, completion: (([URL]?, Error?) -> Void)) {
253253
do {
254254
let contents = try FileManager.default.contentsOfDirectory(at: path, includingPropertiesForKeys: nil, options: skip == true ? FileManager.DirectoryEnumerationOptions.skipsHiddenFiles : FileManager.DirectoryEnumerationOptions(rawValue: 0))
255-
completion(contents: contents, error: nil)
255+
completion(contents, nil)
256256
} catch let e as NSError {
257-
return completion(contents: nil, error: e)
257+
return completion(nil, e)
258258
}
259259
}
260260

@@ -266,12 +266,12 @@ public struct File {
266266
- Parameter completion: An optional completion block when the operation
267267
is done.
268268
*/
269-
public static func writeToPath(_ path: URL, name: String, value: String, completion: ((success: Bool, error: Error?) -> Void)? = nil) {
269+
public static func writeToPath(_ path: URL, name: String, value: String, completion: ((Bool, Error?) -> Void)? = nil) {
270270
do{
271271
try value.write(to: path.appendingPathComponent("/\(name)"), atomically: true, encoding: String.Encoding.utf8)
272-
completion?(success: true, error: nil)
272+
completion?(true, nil)
273273
} catch let e as NSError {
274-
completion?(success: false, error: e)
274+
completion?(false, e)
275275
}
276276
}
277277

@@ -281,11 +281,11 @@ public struct File {
281281
- Parameter completion: An optional completion block when the operation
282282
is done.
283283
*/
284-
public static func readFromPath(_ path: URL, completion: ((string: String?, error: Error?) -> Void)) {
284+
public static func readFromPath(_ path: URL, completion: ((String?, Error?) -> Void)) {
285285
if let data = try? Data(contentsOf: path) {
286-
completion(string: String(data: data, encoding: String.Encoding.utf8), error: nil)
286+
completion(String(data: data, encoding: String.Encoding.utf8), nil)
287287
} else {
288-
completion(string: nil, error: NSError(domain: "io.graph.File", code: 0, userInfo: nil))
288+
completion(nil, NSError(domain: "io.cosmicmind.Graph.File", code: 0, userInfo: nil))
289289
}
290290
}
291291

Sources/Graph.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class Graph: NSObject {
8080
- Parameter success: A boolean indicating if the cloud connection
8181
is possible or not.
8282
*/
83-
internal var completion: ((supported: Bool, error: Error?) -> Void)?
83+
internal var completion: ((Bool, Error?) -> Void)?
8484

8585
/// Deinitializer that removes the Graph from NSNotificationCenter.
8686
deinit {
@@ -112,7 +112,7 @@ public class Graph: NSObject {
112112
- Parameter completion: An Optional completion block that is
113113
executed to determine if iCloud support is available or not.
114114
*/
115-
public init(cloud: String, completion: ((supported: Bool, error: Error?) -> Void)? = nil) {
115+
public init(cloud: String, completion: ((Bool, Error?) -> Void)? = nil) {
116116
route = "Cloud/\(cloud)"
117117
name = cloud
118118
type = NSSQLiteStoreType

Sources/ManagedAction.swift

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ internal class ManagedAction: ManagedNode {
5050
/**
5151
Access properties using the subscript operator.
5252
- Parameter name: A property name value.
53-
- Returns: The optional AnyObject value.
53+
- Returns: The optional Any value.
5454
*/
55-
internal override subscript(name: String) -> AnyObject? {
55+
internal override subscript(name: String) -> Any? {
5656
get {
5757
return super[name]
5858
}
@@ -63,20 +63,24 @@ internal class ManagedAction: ManagedNode {
6363
moc.performAndWait { [unowned self, unowned moc] in
6464
guard let object = value else {
6565
for property in self.propertySet {
66-
if name == property.name {
67-
(property as? ManagedActionProperty)?.delete()
68-
break
66+
if let p = property as? ManagedActionProperty {
67+
if name == p.name {
68+
p.delete()
69+
break
70+
}
6971
}
7072
}
7173
return
7274
}
7375

7476
var exists: Bool = false
7577
for property in self.propertySet {
76-
if name == property.name {
77-
(property as? ManagedActionProperty)?.object = object
78-
exists = true
79-
break
78+
if let p = property as? ManagedActionProperty {
79+
if name == p.name {
80+
p.object = object
81+
exists = true
82+
break
83+
}
8084
}
8185
}
8286

@@ -91,13 +95,13 @@ internal class ManagedAction: ManagedNode {
9195
Adds a tag to the ManagedAction.
9296
- Parameter tag: A tag name.
9397
*/
94-
internal func add(tag: String) {
98+
internal func add(tag name: String) {
9599
guard let moc = managedObjectContext else {
96100
return
97101
}
98102
moc.performAndWait { [unowned self, unowned moc] in
99-
if !self.has(tag: tag) {
100-
_ = ManagedActionTag(name: tag, node: self, managedObjectContext: moc)
103+
if !self.has(tag: name) {
104+
_ = ManagedActionTag(name: name, node: self, managedObjectContext: moc)
101105
}
102106
}
103107
}
@@ -106,15 +110,17 @@ internal class ManagedAction: ManagedNode {
106110
Removes a tag from a ManagedAction.
107111
- Parameter tag: A tag name.
108112
*/
109-
internal func remove(tag: String) {
113+
internal func remove(tag name: String) {
110114
guard let moc = managedObjectContext else {
111115
return
112116
}
113117
moc.performAndWait { [unowned self] in
114-
for t in self.tagSet {
115-
if tag == t.name {
116-
(t as? ManagedActionTag)?.delete()
117-
break
118+
for tag in self.tagSet {
119+
if let t = tag as? ManagedActionTag {
120+
if name == t.name {
121+
t.delete()
122+
break
123+
}
118124
}
119125
}
120126
}
@@ -144,10 +150,12 @@ internal class ManagedAction: ManagedNode {
144150
return
145151
}
146152
moc.performAndWait { [unowned self] in
147-
for g in self.groupSet {
148-
if group == g.name {
149-
(g as? ManagedActionGroup)?.delete()
150-
break
153+
for grp in self.groupSet {
154+
if let g = grp as? ManagedActionGroup {
155+
if group == g.name {
156+
g.delete()
157+
break
158+
}
151159
}
152160
}
153161
}
@@ -200,35 +208,35 @@ internal class ManagedAction: ManagedNode {
200208
}
201209

202210
moc.performAndWait { [unowned self] in
203-
self.propertySet.forEach { (object: AnyObject) in
211+
self.propertySet.forEach { (object: Any) in
204212
guard let property = object as? ManagedActionProperty else {
205213
return
206214
}
207215
property.delete()
208216
}
209217

210-
self.tagSet.forEach { (object: AnyObject) in
218+
self.tagSet.forEach { (object: Any) in
211219
guard let tag = object as? ManagedActionTag else {
212220
return
213221
}
214222
tag.delete()
215223
}
216224

217-
self.groupSet.forEach { (object: AnyObject) in
225+
self.groupSet.forEach { (object: Any) in
218226
guard let group = object as? ManagedActionGroup else {
219227
return
220228
}
221229
group.delete()
222230
}
223231

224-
// self.subjectSet.forEach { [unowned self] (object: AnyObject) in
232+
// self.subjectSet.forEach { [unowned self] (object: Any) in
225233
// guard let managedEntity: ManagedEntity = object as? ManagedEntity else {
226234
// return
227235
// }
228236
// self.mutableSetValueForKey("subjectSet").removeObject(managedEntity)
229237
// }
230238
//
231-
// self.objectSet.forEach { [unowned self] (object: AnyObject) in
239+
// self.objectSet.forEach { [unowned self] (object: Any) in
232240
// guard let managedEntity: ManagedEntity = object as? ManagedEntity else {
233241
// return
234242
// }

Sources/ManagedActionProperty.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal class ManagedActionProperty: ManagedProperty {
4242
- Parameter node: A ManagedAction.
4343
- Parameter managedObjectContext: A reference to a NSManagedObjectContext.
4444
*/
45-
internal convenience init(name: String, object: AnyObject, node: ManagedAction, managedObjectContext: NSManagedObjectContext) {
45+
internal convenience init(name: String, object: Any, node: ManagedAction, managedObjectContext: NSManagedObjectContext) {
4646
self.init(identifier: ModelIdentifier.actionPropertyName, name: name, object: object, managedObjectContext: managedObjectContext)
4747
self.node = node
4848
}

0 commit comments

Comments
 (0)