I think the user can use an external keyboard via Bluetooth, so it is better to provide for the input of both a dot and a comma:
func replaceComma(str: String) - Double {
if let range = str.range(of: ",") {
let testStr = str.replacingCharacters(in: range, with: ".")
return Double(testStr) ?? 0
} else {
return Double(str) ?? 0
}
}