How would I parse a domain name in Objective-C?
For example if my string value was “http://www.google.com” I would like to parse out the string “google”
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think the question is a tiny bit invalid. A host is determined by its FQDN (fully qualified domain name) which, in your example, is http://www.google.com. It’s not the same as mail.google.com or http://www.google.info or google.com. To single out “google” is not trivial and does not make much sense from URL perspective.
If you’d like to just parse the URL more-or-less intelligently, I think you can do the following: