 |
|
 |
|
Next: Beginner: Network activity
|
| Author |
Message |
External

Since: Mar 08, 2004 Posts: 10
|
(Msg. 1) Posted: Mon Mar 08, 2004 5:05 am
Post subject: accessing command line arguments in AppKit? Archived from groups: comp>sys>mac>programmer>help (more info?)
|
|
|
I'm sure that this has got to be easy to do, I just can't find it.
But I have a cocoa app (GUI/AppKit) that I'd like to be able to invoke
from the command line and hand in a few arguments from there. And I
haven't been able to track down how to access them.
I've got the standard main function that does the return
NSApplicationMain(argc, argv), so I know that the args are handed in
somewhere, I just don't know where that is.
So how do I access them from within my program?
-Jim...... |
|
| Back to top |
|
 |  |
External

Since: Mar 01, 2004 Posts: 20
|
(Msg. 2) Posted: Mon Mar 08, 2004 8:09 am
Post subject: Re: accessing command line arguments in AppKit? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Mon, 8 Mar 2004, Jim Thomason wrote:
> I'm sure that this has got to be easy to do, I just can't find it.
>
> But I have a cocoa app (GUI/AppKit) that I'd like to be able to invoke
> from the command line and hand in a few arguments from there. And I
> haven't been able to track down how to access them.
>
> I've got the standard main function that does the return
> NSApplicationMain(argc, argv), so I know that the args are handed in
> somewhere, I just don't know where that is.
>
> So how do I access them from within my program?
One way is to simple access them from main(). ObjC isn't magic, and your
main() function works just like it does in any other app. A more Cocoa-ish
way is to use NSProcessInfo. |
|
| Back to top |
|
 |  |
External

Since: Jul 22, 2003 Posts: 117
|
(Msg. 3) Posted: Mon Mar 08, 2004 7:23 pm
Post subject: Re: accessing command line arguments in AppKit? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <67f2a799.0403081105.23f2871c.DeleteThis@posting.google.com>,
thomasoniii.DeleteThis@yahoo.com (Jim Thomason) wrote:
> So how do I access them from within my program?
NSProcessInfo, a Foundation class. |
|
| Back to top |
|
 |  |
External

Since: Mar 01, 2004 Posts: 20
|
(Msg. 4) Posted: Tue Mar 09, 2004 3:31 am
Post subject: Re: accessing command line arguments in AppKit? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Tue, 9 Mar 2004, Jim Thomason wrote:
> But now I'm really stumped. I was hopeful that I could get data handed
> to me in a useful fashion as an argument, but alas, it is not to be.
> When called from another program, I get an argument of "-psn_0_36306945"
> (or some other similar number). And I haven't been able to track down
> the documentation to tell me what that is or how I deal with it.
It comes from the Finder, or Launch Services, or something, and it's there
to set up various internal stuff. You can (and should) ignore it. |
|
| Back to top |
|
 |  |
External

Since: Mar 03, 2004 Posts: 7
|
(Msg. 5) Posted: Tue Mar 09, 2004 6:53 am
Post subject: Re: accessing command line arguments in AppKit? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <20040308140757.Q18253 DeleteThis @agamemnon.twistedsys.net>,
Michael Ash <mikeash DeleteThis @mikeash.com> wrote:
> One way is to simple access them from main(). ObjC isn't magic, and your
> main() function works just like it does in any other app. A more Cocoa-ish
> way is to use NSProcessInfo.
Excellent. Progress!
But now I'm really stumped. I was hopeful that I could get data handed
to me in a useful fashion as an argument, but alas, it is not to be.
When called from another program, I get an argument of "-psn_0_36306945"
(or some other similar number). And I haven't been able to track down
the documentation to tell me what that is or how I deal with it.
I assume that it's gotta be a key into a lookup table somewhere that'll
give me the actual argument passed, but I don't know where to look.
So who'll point me in the right direction?
-Jim..... |
|
| Back to top |
|
 |  |
External

Since: Mar 08, 2004 Posts: 10
|
(Msg. 6) Posted: Wed Mar 10, 2004 12:55 am
Post subject: Re: accessing command line arguments in AppKit? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Okay, I'm stumped. Specifically what I'm looking at doing is handling
a mailto: link received from a web browser. When someone clicks on a
mailto:, it sends the link to whatever the default email reader is.
And, somehow (magically!) that program figures out the link that was
passed, and hence the email address being sent to.
But I haven't been able to track down how that information is passed.
I've looked in the arguments.
I've looked at standard in.
I've tried to see if there's a current apple event (none, AFAIK, but
I'm not positive I'm looking properly).
I've looked at the general pasteboard.
The only thing that has any data on it is the argument list, where the
second one passed is that -psn number I mentioned in an earlier post.
So I'm stumped. Where should I look to get this information?
-Jim...... |
|
| Back to top |
|
 |  |
External

Since: May 10, 2004 Posts: 1194
|
(Msg. 7) Posted: Wed Mar 10, 2004 6:08 am
Post subject: Re: accessing command line arguments in AppKit? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <67f2a799.0403100655.4269611a RemoveThis @posting.google.com>,
thomasoniii RemoveThis @yahoo.com (Jim Thomason) wrote:
> Okay, I'm stumped. Specifically what I'm looking at doing is handling
> a mailto: link received from a web browser. When someone clicks on a
> mailto:, it sends the link to whatever the default email reader is.
> And, somehow (magically!) that program figures out the link that was
> passed, and hence the email address being sent to.
It comes in a GURL Apple event. See <http://www.scripting.com/midas/geturl.html>
hth
meeroh
--
If this message helped you, consider buying an item
from my wish list: <http://web.meeroh.org/wishlist> |
|
| Back to top |
|
 |  |
External

Since: Mar 08, 2004 Posts: 10
|
(Msg. 8) Posted: Thu Mar 11, 2004 1:48 am
Post subject: Re: accessing command line arguments in AppKit? [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Miro Jurisic <macdev.RemoveThis@meeroh.org> wrote in message news:<macdev-B978BF.12083010032004.RemoveThis@senator-bedfellow.mit.edu>...
> In article <67f2a799.0403100655.4269611a.RemoveThis@posting.google.com>,
> thomasoniii.RemoveThis@yahoo.com (Jim Thomason) wrote:
>
> > Okay, I'm stumped. Specifically what I'm looking at doing is handling
> > a mailto: link received from a web browser. When someone clicks on a
> > mailto:, it sends the link to whatever the default email reader is.
> > And, somehow (magically!) that program figures out the link that was
> > passed, and hence the email address being sent to.
>
> It comes in a GURL Apple event. See <http://www.scripting.com/midas/geturl.html>
>
That doesn't seem to work. I tried setting the suite and eventid to
'GURL' and 'FURL', in the various combinations, and had no success.
GURL and/or FURL as barewords give an error at compile time, NSStrings
bitch about casting, single quotes work. So it doesn't seem right to
me.
-Jim........ |
|
| Back to top |
|
 |  |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|