diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm index 4732009ade3513..7336b27f225cee 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm @@ -138,8 +138,7 @@ - (nullable instancetype)initWithController:(MTRDeviceController *)controller return nil; } } - _nodesWithResumptionInfo = [NSMutableArray arrayWithCapacity:[resumptionNodeList count]]; - [_nodesWithResumptionInfo addObjectsFromArray:resumptionNodeList]; + _nodesWithResumptionInfo = [resumptionNodeList mutableCopy]; } else { _nodesWithResumptionInfo = [[NSMutableArray alloc] init]; } @@ -184,7 +183,7 @@ - (void)storeResumptionInfo:(MTRCASESessionResumptionInfo *)resumptionInfo // Update our resumption info node list. [_nodesWithResumptionInfo addObject:resumptionInfo.nodeID]; [_storageDelegate controller:_controller - storeValue:[NSArray arrayWithArray:_nodesWithResumptionInfo] + storeValue:[_nodesWithResumptionInfo copy] forKey:sResumptionNodeListKey securityLevel:MTRStorageSecurityLevelSecure sharingType:MTRStorageSharingTypeNotShared]; @@ -349,6 +348,9 @@ - (void)encodeWithCoder:(NSCoder *)coder NSSet * MTRDeviceControllerStorageClasses() { + // This only needs to return the classes for toplevel things we are storing, + // plus NSNumber because some archivers use that internally to store + // information about what's being archived. static NSSet * const sStorageClasses = [NSSet setWithArray:@[ [NSNumber class], [NSData class],