Skip to content

Commit 8a9e385

Browse files
jmwskiryanwilson
andauthored
Make getDataWithCompletionBlock snapshot nullable (#9655)
* Make getDataWithCompletionBlock snapshot nullable * fix DatabaseAPITests * update changelog * fix changelog * breaking change * Capitalize Swift Co-authored-by: Ryan Wilson <[email protected]>
1 parent c6a83eb commit 8a9e385

File tree

7 files changed

+13
-10
lines changed

7 files changed

+13
-10
lines changed

FirebaseDatabase/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v8.12.0
2+
- [fixed] **Breaking change:** Mark `getData()` snapshot as nullable to fix Swift API. (#9655)
3+
14
# v8.11.0
25
- [fixed] Race condition crash in FUtilities.m. (#9096)
36
- [fixed] FNextPushId 'successor' crash. (#8790)

FirebaseDatabase/Sources/Api/FIRDatabaseQuery.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,9 @@ - (void)keepSynced:(BOOL)keepSynced {
663663
});
664664
}
665665

666-
- (void)getDataWithCompletionBlock:(void (^)(NSError *__nullable error,
667-
FIRDataSnapshot *snapshot))block {
666+
- (void)getDataWithCompletionBlock:
667+
(void (^)(NSError *__nullable error,
668+
FIRDataSnapshot *__nullable snapshot))block {
668669
dispatch_async([FIRDatabaseQuery sharedQueue], ^{
669670
[self.repo getData:self withCompletionBlock:block];
670671
});

FirebaseDatabase/Sources/Core/FRepo.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,8 @@ - (void)purgeOutstandingWrites {
519519
}
520520

521521
- (void)getData:(FIRDatabaseQuery *)query
522-
withCompletionBlock:
523-
(void (^_Nonnull)(NSError *__nullable error,
524-
FIRDataSnapshot *__nullable snapshot))block {
522+
withCompletionBlock:(void (^)(NSError *__nullable error,
523+
FIRDataSnapshot *__nullable snapshot))block {
525524
FQuerySpec *querySpec = [query querySpec];
526525
id<FNode> node = [self.serverSyncTree getServerValue:[query querySpec]];
527526
if (node != nil) {

FirebaseDatabase/Sources/FIRDatabaseReference.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ - (void)observeSingleEventOfType:(FIRDataEventType)eventType
445445

446446
- (void)getDataWithCompletionBlock:
447447
(void (^_Nonnull)(NSError *__nullable error,
448-
FIRDataSnapshot *snapshot))block {
448+
FIRDataSnapshot *__nullable snapshot))block {
449449
[super getDataWithCompletionBlock:block];
450450
}
451451

FirebaseDatabase/Sources/Public/FirebaseDatabase/FIRDatabaseQuery.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ NS_SWIFT_NAME(DatabaseQuery)
141141
*/
142142
- (void)getDataWithCompletionBlock:
143143
(void (^_Nonnull)(NSError *__nullable error,
144-
FIRDataSnapshot *snapshot))block
144+
FIRDataSnapshot *__nullable snapshot))block
145145
NS_SWIFT_NAME(getData(completion:));
146146

147147
/**

FirebaseDatabase/Sources/Public/FirebaseDatabase/FIRDatabaseReference.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ priority is meant to be preserved, you should use setValue:andPriority: instead.
377377
*/
378378
- (void)getDataWithCompletionBlock:
379379
(void (^_Nonnull)(NSError *__nullable error,
380-
FIRDataSnapshot *snapshot))block
380+
FIRDataSnapshot *__nullable snapshot))block
381381
NS_SWIFT_NAME(getData(completion:));
382382

383383
#pragma mark - Detaching observers

FirebaseDatabase/Tests/Unit/Swift/DatabaseAPITests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ final class DatabaseAPITests {
109109
// getData(completion block:)
110110
databaseQuery.getData { optionalError, dataSnapshot in
111111
let /* optionalError */ _: Error? = optionalError
112-
let /* dataSnapshot */ _: DataSnapshot = dataSnapshot
112+
let /* dataSnapshot */ _: DataSnapshot? = dataSnapshot
113113
}
114114

115115
#if compiler(>=5.5.2) && canImport(_Concurrency)
@@ -388,7 +388,7 @@ final class DatabaseAPITests {
388388
// getData(completion block:)
389389
databaseReference.getData { optionalError, dataSnapshot in
390390
let /* optionalError */ _: Error? = optionalError
391-
let /* dataSnapshot */ _: DataSnapshot = dataSnapshot
391+
let /* dataSnapshot */ _: DataSnapshot? = dataSnapshot
392392
}
393393

394394
#if compiler(>=5.5.2) && canImport(_Concurrency)

0 commit comments

Comments
 (0)