0

I was trying out the tutorial of building a simple web browser using UIWebView. In which there is feature to prefix the scheme "http://" to the url if user just types in the address without any scheme. For Ex: user types in google.com instead of http://google.com This is achieved using the NSURL's scheme property. All is well until the address is simple.

If the address is something like this: "test1.samplewebsite.com:81" NSURL scheme detect the string "test1.samplewebsite.com" as scheme instead of no scheme.

This works fine on safari, it detects no scheme and promptly prefixes http.

Before jumping into writing code to detect scheme, I wanted to check, Is there any system API's for detecting valid scheme?

user1150393
  • 139
  • 1
  • 15

1 Answers1

0

Unfortunately in your example, test1.samplewebsite.com would be the scheme according to the spec (or whatever wikipedia said, since I'm not much of a spec reader).

But you can use the -[UIApplication canOpenURL:(NSURL *)] to determine if the device can open the given scheme, custom or otherwise. Here's a link to UIApplication docs (I wish I could link directly to the method).

Jeff
  • 5,013
  • 1
  • 33
  • 30