diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index 2107685d853b74e4d0f5aa5b64cc98cd492fefd5..8b7055815d3e7423ab8f45cf0bf9fd99a3d063f0 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -59,11 +59,11 @@ [NSException raise:NSInvalidArgumentException format:@"Invalid URL: %@", host]; } if ([hostURL.scheme isEqualToString:@"https"]) { - host = [hostURL.host stringByAppendingString:hostURL.port.stringValue ?: @":443"]; + host = [@[hostURL.host, hostURL.port ?: @443] componentsJoinedByString:@":"]; return [[GRPCSecureChannel alloc] initWithHost:host]; } if ([hostURL.scheme isEqualToString:@"http"]) { - host = [hostURL.host stringByAppendingString:hostURL.port.stringValue ?: @":80"]; + host = [@[hostURL.host, hostURL.port ?: @80] componentsJoinedByString:@":"]; return [[GRPCUnsecuredChannel alloc] initWithHost:host]; } [NSException raise:NSInvalidArgumentException