Skip to content

Commit 8a060fc

Browse files
committed
Work around Swift bridging optionals incorrectly in Xcode 16.3
1 parent 6cb5f03 commit 8a060fc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Realm/RLMArray.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,10 @@ - (void)replaceAllObjectsWithObjects:(NSArray *)objects {
365365
}
366366
changeArray(self, NSKeyValueChangeInsertion, NSMakeRange(0, objects.count), ^{
367367
for (id object in objects) {
368-
[_backingCollection addObject:object];
368+
// object should always be non-nil since it's a value stored in a
369+
// NSArray, but as of Xcode 16.3 [Decimal128?] sometimes ends up
370+
// with nil instead of NSNull when bridged from Swift.
371+
[_backingCollection addObject:object ?: NSNull.null];
369372
}
370373
});
371374
}

Realm/RLMSet.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ - (void)replaceAllObjectsWithObjects:(NSArray *)objects {
279279
return;
280280
}
281281
for (id object in objects) {
282-
[_backingCollection addObject:object];
282+
// object should always be non-nil since it's a value stored in a
283+
// NSArray, but as of Xcode 16.3 [Decimal128?] sometimes ends up
284+
// with nil instead of NSNull when bridged from Swift.
285+
[_backingCollection addObject:object ?: NSNull.null];
283286
}
284287
});
285288
}

0 commit comments

Comments
 (0)