If a user omits this prefix in browser the page will not load Anyone knows how to add http:// prefix to UITextField if user omits it? thanks
Asked
Active
Viewed 1,185 times
1
-
Take look at http://stackoverflow.com/questions/3789126/check-if-an-url-has-got-http-prefix/3789436#3789436 – GlennRay Sep 10 '15 at 23:18
-
Thanks for reply,but i want in swift language not objective c – Sep 11 '15 at 08:51
1 Answers
2
i've checked the previous answers for objective-c solutions, and i thought to do it in the simple way: add the prefix if it's not there in the textfield, using "hasprefix":
if(!textField.text!.hasPrefix("http://")){
textField.text = "http://" + textField.text!
}
there's corner here which is https case, but this will fix the current situation.

sourav
- 779
- 5
- 14

Abdoelrhman
- 906
- 8
- 17