}
</pre>
===非同期処理===
<pre>
let c = {
(ip:String) -> String in
let hostName = getHostName(ip: ip) // 時間がかかる処理
return hostName
}
let que = DispatchQueue.global(qos: .default)
for host in hosts.hosts {
print("CALL-\(host.ip)")
que.async { // 非同期処理
let hostname = c(host.ip) // 時間がかかる処理
DispatchQueue.main.async { // 画面に反映
host.host = hostname
}
}
}
</pre>
==[[正規表現]]==
===arp -a の結果からIPアドレスを抜きだす===