1

This has me stumped, I am trying to get a the string of NWPathMonitor. If I print NWPathMonitor I get this:

"satisfied (Path is satisfied), interface: en0, ipv4, dns"

How can I get the same text in a string.

let interface = NWPathMonitor() // get the NWPathMonitor in a variable

let interfaceString = String(pathMonitor) // change that variable to a string

So the second line gives me "No exact matches in call to initializer."

It's seems that NWPathMonitor() has a lot of info and I am not clearly specifying what I want.

Any idea how can I get the same line that prints "satisfied (Path is satisfied), interface: en0, ipv4, dns" into a string variable?

Ramesh Sanghar
  • 174
  • 1
  • 1
  • 19
moonmonkey
  • 125
  • 9
  • 2
    have you tried: `let interfaceString = interface.currentPath.debugDescription`. Or, `interface.pathUpdateHandler = { path in print("---> path: \(path.debugDescription)") }` – workingdog support Ukraine Sep 29 '22 at 04:31
  • 1
    You say that if you print `NWPathMonitor`, you get "satisfied (Path is satisfied), interface: en0, ipv4, dns". How exactly? `print(interface)` prints just "Network.NWPathMonitor". – lazarevzubov Sep 29 '22 at 04:39
  • 1
    Do you actually need that string? (""satisfied (Path is satisfied), interface: en0, ipv4, dns") I use the path.status and switch on this value to know if the path has a connection – nivbp Jan 12 '23 at 11:08

0 Answers0