Search This Blog

Tuesday, October 11, 2016

iOS Swift. How to check validity of URL in Swift?

There is system method to check validity of URL -  UIApplication.shared.canOpenURL(url as URL)
import Foundation
import UIKit

extension NSURL {
    func verifyUrl () -> Bool {
        //Check for nil
        if let urlString = self.absoluteString {
            // create NSURL instance
            if let url = NSURL(string: urlString) {
                // check if your application can open the NSURL instance
                return UIApplication.shared.canOpenURL(url as URL)
            }
        }
        return false
    }
}

6 comments:

  1. Thanks for sharing such useful information. Thanks You I Read Your article its really informative. Keep up the good work. I hope to see more interesting articles from you.
    -Custom Website Design Company

    ReplyDelete
  2. Your article is one of its kind which explained every bit of Custom Build Website. looking for further valuable articles from you

    ReplyDelete
  3. This post wowed me with its well-researched content and excellent writing. Because I was so involved in this book, I couldn't put it down. Your work and ability have wowed me. Thank you very much. Those who want to learn more about it may find it useful. Best Custom Websites

    ReplyDelete
  4. Your article is unbelievable with precise knowledge. I can see a lot of research behind that and that is beyond my expectations.
    Create Your Own Website \

    ReplyDelete
  5. Good content. I was looking for this type of content. Saved my time for further search.
    You should always provide that type of content. I appreciate your determination to give the students a good title.Custom Designed Websites

    ReplyDelete
  6. Amazing write-up! The blog was very informative. Keep it up!
    Custom Website Development

    ReplyDelete