Skip to content

Instantly share code, notes, and snippets.

@hsleedevelop
Created May 11, 2017 13:38
Show Gist options
  • Save hsleedevelop/26f51a0308d52fe60579ff0de5f13b37 to your computer and use it in GitHub Desktop.
Save hsleedevelop/26f51a0308d52fe60579ff0de5f13b37 to your computer and use it in GitHub Desktop.
flatmap usage
let sdevices = devices.flatMap({ (device: Device) -> String in
return "\(device.brand)-\(device.hostname)-\(device.ipAddress)-\(device.macAddress)\n"
}).flatMap({$0}).joined()
DispatchQueue.main.async {
JDAlert(title: "Found \(devices.count) Device(s).", message: sdevices, preferredStyle: .alert)
.addAction(title: "OK", style: .default) { _ in }
.show()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment