r/ObjectiveC • u/Aviav123 • Sep 02 '21
How to open up URL which is part of NSString?
Hi, I've got a string for exmaple like this - "sadsadsad https://www.youtube.com/results?search_query=martin+garrix"
How can I open up that url which is a part of NSString?
5
Upvotes
5
u/[deleted] Sep 02 '21
NSDataDetector can find links in text https://www.hackingwithswift.com/example-code/strings/how-to-detect-a-url-in-a-string-using-nsdatadetector
3
u/whackylabs Sep 02 '21
split it by whitespace and take the URL component
1
u/NasStillmatic Sep 28 '21
https://stackoverflow.com/a/4590734
-1
u/MrSloppyPants Sep 02 '21
Use a Regular Expression. If your URL will,always be fully qualified, you can use…