I\'m trying to use Apple\'s class: Simple Ping, but I can\'t get this working.
When I\'m running example mac os x project it\'s working:
2015-06-1
Not sure why this doesn't work, but you can call the ping method yourself once the address is resolved.
A variable to tell you that you can start pinging:
var canStartPinging = false
The code that calls the ping:
let pinger = SimplePing(hostName: "www.apple.com")
pinger.delegate = self;
pinger.start()
do {
if (canStartPinging) {
pinger.sendPingWithData(nil)
}
NSRunLoop.currentRunLoop().runMode(NSDefaultRunLoopMode, beforeDate: NSDate.distantFuture() as! NSDate)
} while(pinger != nil)
The SimplePing
delegate method to wait for before you can start pinging:
func simplePing(pinger: SimplePing!, didStartWithAddress address: NSData!) {
println("didStartWithAddress")
canStartPinging = true
}