How can I launch the Safari browser or the user’s default browser pointing it to a specific address from within my Mac application?
I am using Objective-C as the programming language.
Thanks.
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.
From a shell you can use the
opencommand with a URL as a parameter, and that takes care of opening that URL in the default browser.So you should be able to use
system()or similarfork()/exec()code to do the same.nb:
openwill also open other sorts of files / URLs, too, so make sure it really is a web URL you’re trying to open otherwise you’ve got a probable security problem.The Objective C way of doing it appears to be:
where
urlis a pointer to an NSURL object