Open Safari from a Application

Discussion in 'Mac Programming' started by satyam90, Oct 19, 2007.

  1. satyam90 macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #1
    Hi,

    In my application I am providing a html file.
    I am having a button in my dialog. On clicking that buton, i want to show the html file in Safari (or any other browser that is available). How to do this.

    Regards,
    Satyam.
     
  2. hhas macrumors regular

    Joined:
    Oct 15, 2007
    #2
    If it's a help file, don't forget that OS X provides a standard framework for dealing with those. Otherwise, you could use something like the following, which will open a resource file using the default application for that file type:

    Code:
    NSString *path = [[NSBundle mainBundle] pathForResource: @"yourfile" ofType: @"html"];
    BOOL success = [[NSWorkspace sharedWorkspace] openFile: path];
     
  3. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #3
    You could use an Applescript to open Safari and then display the file in question.

    Other options include using fork and exec.

    Using 'system'

    Using NSTask.
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    There's also Launch Services
     

Share This Page