Invoking Safari through simple cocoa application

Discussion in 'Mac Programming' started by shweta13, Aug 11, 2008.

  1. shweta13 macrumors member

    Aug 7, 2008
    Hi everyone,

    I am unable to invoke safari application through my simple cocoa windows application.
    Can someone help?

    P.S. I am not using any view based application.
  2. cMacSW macrumors regular

    Mar 20, 2006
    How about using NSWorkspaces openURL: method?
  3. hhas macrumors regular

    Oct 15, 2007
    The OP isn't specific about what they want to do, but if all they want is to open a webpage then I'd second the above, particularly as it'll work with the user's default browser even if it isn't Safari.

    OTOH, if they want to interact in some other way, or with Safari in particular, then Apple events are the way to go, either by executing an embedded AppleScript via NSAppleScript (crude, but may be sufficient for simple tasks), or using one of the available ObjC-Apple event bridges (e.g. objc-appscript's svn repository contains a sample project that shows how how to fetch the URL from the front Safari document).

Share This Page