Skip to content

Commit 0bf46a3

Browse files
authored
[Database] Replace deprecated NSKeyedUnarchiver method in FLevelDBStorageEngine (#11479)
Replaced use of the deprecated `unarchiveObjectWithData:` method with `unarchivedObjectOfClasses:fromData:error:`, available in iOS 11+ (above our minimum deployment target).
1 parent 0da1e62 commit 0bf46a3

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

FirebaseDatabase/Sources/Persistence/FLevelDBStorageEngine.m

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,18 @@ - (void)runLegacyMigration:(FRepoInfo *)info {
166166
// it'll go fine :P
167167
[writes enumerateKeysAndValuesAsData:^(NSString *key, NSData *data,
168168
BOOL *stop) {
169-
#pragma clang diagnostic push
170-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
171-
// Update the deprecated API when minimum iOS version is 11+.
172-
id pendingPut = [NSKeyedUnarchiver unarchiveObjectWithData:data];
173-
#pragma clang diagnostic pop
174-
if ([pendingPut isKindOfClass:[FPendingPut class]]) {
169+
NSError *error;
170+
id pendingPut = [NSKeyedUnarchiver
171+
unarchivedObjectOfClasses:
172+
[NSSet setWithObjects:[FPendingPut class],
173+
[FPendingPutPriority class],
174+
[FPendingUpdate class], nil]
175+
fromData:data
176+
error:&error];
177+
if (error) {
178+
FFWarn(@"I-RDB076003", @"Failed to migrate legacy write: %@",
179+
error);
180+
} else if ([pendingPut isKindOfClass:[FPendingPut class]]) {
175181
FPendingPut *put = pendingPut;
176182
id<FNode> newNode =
177183
[FSnapshotUtilities nodeFrom:put.data
@@ -205,7 +211,9 @@ - (void)runLegacyMigration:(FRepoInfo *)info {
205211
numberOfWritesRestored++;
206212
} else {
207213
FFWarn(@"I-RDB076003",
208-
@"Failed to migrate legacy write, meh!");
214+
@"Failed to migrate legacy write: unrecognized class "
215+
@"\"%@\"",
216+
[pendingPut class]);
209217
}
210218
}];
211219
FFWarn(@"I-RDB076004", @"Migrated %lu writes",

0 commit comments

Comments
 (0)