• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: launch safari to open an url
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: launch safari to open an url


  • Subject: Re: launch safari to open an url
  • From: Hernan Ochoa <email@hidden>
  • Date: Sun, 15 May 2005 13:59:12 -0300

Hi Ondra!,

it's HerNan! not Herman! :) hihihi :).

Thanks a lot for your answer. I tested your example and it worked great.
I was trying to do the same but from a projet created through XCode,
and it wasn't working.
Now with your working example, I'll try to find out what's going on with XCode.

Why is the [NSAutoreleasePool new]; call needed?

Thanks again!!

On 5/15/05, Ondra Cada <email@hidden> wrote:
> Herman,
>
> On 15.5.2005, at 5:08, Hernan Ochoa wrote:
>
> > I have a command-line tool that uses the Core framework.
> >
> > Can I use NSWorkspace from such an application?
> >
> > I'm trying to launch Safari and open and url with it.
> > I've tried doing this with execl(), but it is impossible.
> > ./Safari http://www.google.com results in Safari opening
> > file://current_directory/http://www.google.com.
> > very frustrating.
> >
> > so, I finally was able to do it with NSWorkspace
> > openUrl:withApplication:.
> >
> > Can I use the NSWorkspace from a command-line tool Xcode project?
> >
>
> Of course. You can freely use any AppKit API, just beware those which
> need the application framework. In those cases you have to create
> NSApplication (but this is not the case we are speaking of).
>
> > I tried addind the appkit framework to my project, but i can't get it
> > to work. doing an #include <AppKit/NSWorkspace.h> throws an error.
> > Thanks in advance.
>
> Strange -- for me, it works without a glitch:
>
> 73 /Users> cd /tmp
> 74 /tmp> >q.m
> #import <Cocoa/Cocoa.h>
> int main() {
> [NSAutoreleasePool new];
> [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://
> www.ocs.cz"]];
> return 0;
> }
> 75 /tmp> cc -Wall -framework Cocoa q.m && ./a.out
> 76 /tmp>
>
> (The URL was opened all right)
> ---
> Ondra Čada
> OCSoftware:     email@hidden               http://www.ocs.cz
> private         email@hidden             http://www.ocs.cz/oc
>
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: launch safari to open an url
      • From: Ondra Cada <email@hidden>
References: 
 >launch safari to open an url (From: Hernan Ochoa <email@hidden>)
 >Re: launch safari to open an url (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: OpenGL and Tiger
  • Next by Date: Re: Application Hang (Cocoa-Java)
  • Previous by thread: Re: launch safari to open an url
  • Next by thread: Re: launch safari to open an url
  • Index(es):
    • Date
    • Thread