Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 9fe9faa

Browse files
committed
Add validatedCurrentConfiguration() that checks for SDK initialization.
1 parent bde80db commit 9fe9faa

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

Sources/ParseLiveQuery.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
0632EDD41CA1A6DB00DD3CB8 /* Parse+LiveQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0632EDD31CA1A6DB00DD3CB8 /* Parse+LiveQuery.swift */; };
11+
0632EDD51CA1A6DB00DD3CB8 /* Parse+LiveQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0632EDD31CA1A6DB00DD3CB8 /* Parse+LiveQuery.swift */; };
1012
629DC3BE90DA87A7857677D2 /* Pods_ParseLiveQuery_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE2643D85A7565FC20EE144C /* Pods_ParseLiveQuery_iOS.framework */; };
1113
DE7126BDB27E5DDB1C21490A /* Pods_ParseLiveQuery_OSX.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF5A55E51D52E372CD28FF08 /* Pods_ParseLiveQuery_OSX.framework */; };
1214
F534A5B21BDAFE0200CBD11A /* Subscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = F534A5B11BDAFE0200CBD11A /* Subscription.swift */; };
@@ -30,6 +32,7 @@
3032
/* End PBXBuildFile section */
3133

3234
/* Begin PBXFileReference section */
35+
0632EDD31CA1A6DB00DD3CB8 /* Parse+LiveQuery.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Parse+LiveQuery.swift"; sourceTree = "<group>"; };
3336
11F6DFE2732DB0DE49976BA5 /* Pods-ParseLiveQuery OSX.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ParseLiveQuery OSX.release.xcconfig"; path = "../Pods/Target Support Files/Pods-ParseLiveQuery OSX/Pods-ParseLiveQuery OSX.release.xcconfig"; sourceTree = "<group>"; };
3437
6062D7994653A4F07D1358B9 /* Pods-ParseLiveQuery iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ParseLiveQuery iOS.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-ParseLiveQuery iOS/Pods-ParseLiveQuery iOS.debug.xcconfig"; sourceTree = "<group>"; };
3538
7A40A16386D0D6B38F8B2F07 /* Pods-ParseLiveQuery-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ParseLiveQuery-iOS.release.xcconfig"; path = "../Pods/Target Support Files/Pods-ParseLiveQuery-iOS/Pods-ParseLiveQuery-iOS.release.xcconfig"; sourceTree = "<group>"; };
@@ -128,6 +131,7 @@
128131
F534A5B11BDAFE0200CBD11A /* Subscription.swift */,
129132
F54D58B51C8E33D9009F8D6C /* ObjCCompat.swift */,
130133
F59CA92E1C8E496200329737 /* Errors.swift */,
134+
0632EDD31CA1A6DB00DD3CB8 /* Parse+LiveQuery.swift */,
131135
F5A88F491C9B6EBA002F0E0D /* PFQuery+Subscribe.swift */,
132136
);
133137
path = ParseLiveQuery;
@@ -324,6 +328,7 @@
324328
files = (
325329
F54D58B81C8E3446009F8D6C /* ClientPrivate.swift in Sources */,
326330
F5D965351BD99DA200C3AAFC /* Client.swift in Sources */,
331+
0632EDD51CA1A6DB00DD3CB8 /* Parse+LiveQuery.swift in Sources */,
327332
F54D58B61C8E33D9009F8D6C /* ObjCCompat.swift in Sources */,
328333
F54D58BA1C8E345F009F8D6C /* BoltsHelpers.swift in Sources */,
329334
F5D965381BD99DA200C3AAFC /* QueryEncoder.swift in Sources */,
@@ -340,6 +345,7 @@
340345
files = (
341346
F5A88F541C9B7341002F0E0D /* ObjCCompat.swift in Sources */,
342347
F5A88F531C9B7341002F0E0D /* Subscription.swift in Sources */,
348+
0632EDD41CA1A6DB00DD3CB8 /* Parse+LiveQuery.swift in Sources */,
343349
F5A88F511C9B7341002F0E0D /* BoltsHelpers.swift in Sources */,
344350
F5A88F501C9B7341002F0E0D /* ClientPrivate.swift in Sources */,
345351
F5A88F551C9B7341002F0E0D /* Errors.swift in Sources */,

Sources/ParseLiveQuery/Client.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,10 @@ public class Client: NSObject {
3333
internal let queue = dispatch_queue_create("com.parse.livequery", DISPATCH_QUEUE_SERIAL)
3434

3535
/**
36-
Creates a Client which automatically attempts to connect to the custom parse-server URL set
37-
in Parse.currentConfiguration
36+
Creates a Client which automatically attempts to connect to the custom parse-server URL set in Parse.currentConfiguration().
3837
*/
3938
public override convenience init() {
40-
self.init(server: Parse.currentConfiguration().server)
39+
self.init(server: Parse.validatedCurrentConfiguration().server)
4140
}
4241

4342
/**
@@ -61,8 +60,8 @@ public class Client: NSObject {
6160
return RequestId(value: currentRequestId)
6261
}
6362

64-
self.applicationId = applicationId ?? Parse.currentConfiguration().applicationId!
65-
self.clientKey = clientKey ?? Parse.currentConfiguration().clientKey
63+
self.applicationId = applicationId ?? Parse.validatedCurrentConfiguration().applicationId!
64+
self.clientKey = clientKey ?? Parse.validatedCurrentConfiguration().clientKey
6665

6766
self.host = components.URL!
6867
}
@@ -94,7 +93,7 @@ extension Client {
9493
dispatch_sync(storage.queue) {
9594
client = storage.client
9695
if client == nil {
97-
let configuration = Parse.currentConfiguration()
96+
let configuration = Parse.validatedCurrentConfiguration()
9897
client = Client(
9998
server: configuration.server,
10099
applicationId: configuration.applicationId,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright (c) 2016-present, Parse, LLC.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
import Parse
11+
12+
extension Parse {
13+
static func validatedCurrentConfiguration() -> ParseClientConfiguration {
14+
let configuration = Parse.currentConfiguration()
15+
assert(configuration != nil,
16+
"Parse SDK is not initialized. Call Parse.initializeWithConfiguration() before loading live query client.")
17+
return configuration!
18+
}
19+
}

0 commit comments

Comments
 (0)