I'm trying to use a completion to write text, but I get the error "Type '()' cannot conform to 'View'; only struct/enum/class types can conform to protocols" when I try to run it. Any help would be great, thank you!
VStack {
Image("external_white")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 60, height: 60.0)
Text("External IP")
getExternalAddress("") { (test) -> Any in
Text(test)
}
}
Called function:
func getExternalAddress(_ key: String, completion: @escaping (String) -> Any) {
var test = key
Ipify.getPublicIPAddress { result in
switch result {
case .success(let ip):
print(ip + " ip") // "210.11.178.112"
test = ip
print(test + " test")
completion(test)
case .failure(let error):
print(error.errorDescription)
}
}