In my application, when the user add an object, can also add a link for this object and then the link can be opened in a webView.
I tried to save a link without http:// prefix, then open it in the webView but that can't open it!
Before webView starts loading, is there a method to check if the URL saved has got http:// prefix? And if it hasn't got it, how can I add the prefix to the URL?
Thanks!
相关问题
- Angular RxJS mergeMap types
- Core Data lightweight migration crashes after App
- React Native Inline style for multiple Text in sin
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- C#使用http访问网络,有办法用指定网卡访问网络嘛?
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- How to get rid of border around and image used as
- Swift - hide pickerView after value selected
- Is a unicode user agent legal inside an HTTP heade
You can use scheme property for check it out. For example...
Better to use the
scheme
property on theURL
object:Example usage:
I wrote an extension for String in Swift, to see if url string got http or https
If you're checking for "http://" you'll probably want case-insensitive search:
Although I think the url scheme check is a better answer depending on your circumstances, as URLs can begin with http or https and other prefixes depending on what your use case is.
You can use the
- (BOOL)hasPrefix:(NSString *)aString
method on NSString to see if an NSString containing your URL starts with the http:// prefix, and if not add the prefix.I'm currently away from my mac and can't compile/test this code, but I believe the above should work.
I am not sure if there is any method to check that but you check it in the code.
try using