how to check if rtmp or hls urls are exist or they'll give 404 error in swift
<p>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: </p>

<pre><code>rtmp://185.23.131.187:1935/live/jomhori1
</code></pre>

<p>or this one :</p>

<pre><code>http://185.23.131.25/hls-live/livepkgr/_defint_/liveevent/livestream.m3u8
</code></pre>

<p>My code to check the validation of the url : </p>

<pre><code>let urlPath: String = "http://185.23.131.25/hls-live/livepkgr/_defint_/liveevent/livestream.m3u8"
                            let url: NSURL = NSURL(string: urlPath)!
                            let request: NSURLRequest = NSURLRequest(URL: url)
                            let response: AutoreleasingUnsafeMutablePointer&lt;NSURLResponse?&gt;=nil

                            var valid : Bool!

                            do {
                                _ = try NSURLConnection.sendSynchronousRequest(request, returningResponse: response)
                            } catch {
                                print("404")
                                valid = false
                            }
</code></pre>

<p>I've searched the web but all the method I found wasn't helpful for my issue.</p>