diff --git a/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm b/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm index b5675ca4f79bbe..1a68ba09781379 100644 --- a/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/MTROTAProviderDelegateBridge.mm @@ -158,7 +158,8 @@ } if (commandData.location.HasValue()) { - commandParams.location = [NSString stringWithUTF8String:commandData.location.Value().data()]; + NSData * locationData = [NSData dataWithBytes:commandData.location.Value().data() length:commandData.location.Value().size()]; + commandParams.location = [[NSString alloc] initWithData:locationData encoding:NSUTF8StringEncoding]; } if (commandData.requestorCanConsent.HasValue()) {