Skip to content

Commit

Permalink
Darwin XPC: allow NSDate typed objects in internalProperties dict…
Browse files Browse the repository at this point in the history
…ionary (#36514)
  • Loading branch information
kiel-apple authored Nov 15, 2024
1 parent 412271b commit cda1c4d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/darwin/Framework/CHIP/MTRDevice_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ - (oneway void)deviceConfigurationChanged:(NSNumber *)nodeID

- (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) {
Expand All @@ -269,7 +270,7 @@ - (BOOL)_internalState:(NSDictionary *)dictionary hasValidValuesForKeys:(const N

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;
}
Expand Down

0 comments on commit cda1c4d

Please sign in to comment.