Darwin XPC: allow `NSDate` typed objects in `internalProperties` dictionary (#36514)
diff --git a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm
index b500633..d535632 100644
--- a/src/darwin/Framework/CHIP/MTRDevice_XPC.mm
+++ b/src/darwin/Framework/CHIP/MTRDevice_XPC.mm
@@ -258,7 +258,8 @@
- (BOOL)_internalState:(NSDictionary *)dictionary hasValidValuesForKeys:(const NSArray<NSString *> *)keys valueRequired:(BOOL)required
{
- // All the keys are NSNumber-valued.
+ // At one point, all keys were NSNumber valued; now there are also NSDates.
+ // TODO: Create a mapping between keys and their expected types and use that in the type check below.
for (NSString * key in keys) {
id value = dictionary[key];
if (!value) {
@@ -269,7 +270,7 @@
continue;
}
- if (!MTR_SAFE_CAST(value, NSNumber)) {
+ if (!MTR_SAFE_CAST(value, NSNumber) && !MTR_SAFE_CAST(value, NSDate)) {
MTR_LOG_ERROR("%@ device:internalStateUpdated: handed state with invalid value for \"%@\": %@", self, key, value);
return NO;
}