I need to parse some data from rss and open related links from parsed rss in swift 2, for example i want to check this link is valid or not:
rtmp://185.23.1
I found a solution here in Objective C, so I ported the code to Swift (though you'll need to test it):
class testHandler: NSObject, NSURLConnectionDelegate{
func testURL(urlPath: String){
let url: NSURL = NSURL(string: urlPath)!
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "HEAD"
let connection = NSURLConnection(request: request, delegate: self)
}
func connection(connection: NSURLConnection,
didReceiveResponse response: NSURLResponse){
if response is NSHTTPURLResponse{
if (response as! NSHTTPURLResponse).statusCode==200{
//url exists
}
}
}
}