title: Swift 3 - Got an empty NetService.addresses array after exploring bonjour
body: <p>I'm pretty new in Swift 3.</p>
  
  <p>I want to get the ip of my NetServices which I explored with bonjour to show them to the user, not to connect with the device. So far I can search for devices with bonjour and get them listed in a listView with this great access code:</p>
  
  <p><a href="https://github.com/ecnepsnai/BonjourSwift" rel="nofollow noreferrer">https://github.com/ecnepsnai/BonjourSwift</a></p>
  
  <p>This is my function to scan the bonjour services and put them into a local array of NetServices:</p>
  
  <pre><code>    // scanning for services, delete old bonjourServices Array and fill it with new discovered services
  
  var bonjourServices = [NetService]()
  
  private func putServicesToArray(){
      let browser: Bonjour = Bonjour()
  
      _ = browser.findService(Bonjour.Services.Line_Printer_Daemon, domain: Bonjour.LocalDomain) { (services) in
  
          self.bonjourServices.removeAll()
  
  
          for service in browser.services {
  
              if !(self.bonjourServices.contains(service)) {
  
                  self.bonjourServices.append(service)
              }
          }
      }
  }
  </code></pre>
  
  <p>I'm using this method to get the ip address, from <a href="https://stackoverflow.com/questions/38197198/swift-3-how-to-resolve-netservice-ip/43054808#43054808">Swift 3 how to resolve NetService IP?</a></p>
  
  <pre><code> func netServiceDidResolveAddress(_ sender: NetService) {
  
      print("netServiceDidResolveAddress get called with \(sender).")
  
      var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
  
      guard let data = sender.addresses?.first else {
          print("guard let data failed")
          return
           }
      do {
          try data.withUnsafeBytes { (pointer:UnsafePointer&lt;sockaddr&gt;) -&gt; Void in
              guard getnameinfo(pointer, socklen_t(data.count), &amp;hostname, socklen_t(hostname.count), nil, 0, NI_NUMERICHOST) == 0 else {
                  throw NSError(domain: "domain", code: 0, userInfo: ["error":"unable to get ip address"])
              }
          }
      } catch {
          print(error)
          return
      }
      let address = String(cString:hostname)
      print("Adress:", address)
  }
  </code></pre>
  
  <p>And with this IBAction I just want to print the ip address, but my ip is empty and my <code>bonjourServices[0].addresses</code> is empty also the addresses.adress NSData Objects</p>
  
  <pre><code>    @IBAction func detectNetwork(_ sender: UIButton) {
      print("putServiceToArray: ")
  
      putServicesToArray()
  
  
      for service in bonjourServices {
          print(service)
      }
  
      bonjourTableView.reloadData()
  
      if !(bonjourServices.isEmpty){
  
          print(netServiceDidResolveAddress(bonjourServices[0]))
          print(bonjourServices[0].addresses)
      }
  
  }
  </code></pre>
  
  <p>Here is my console output:</p>
  
  <pre><code>netServiceDidResolveAddress get called with &lt;NSNetService 0x61800003d6a0&gt; local. _printer._tcp. Brother HL-3152CDW series.
  guard let data failed
  ()
  Optional([])
  </code></pre>
  
  <p>Can you please help me resolve this problem?</p>