• 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: Problem getting correct file URL in NSTask process
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem getting correct file URL in NSTask process


  • Subject: Re: Problem getting correct file URL in NSTask process
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 27 May 2010 07:15:11 -0500

On May 27, 2010, at 6:55 AM, Antonio Nunes wrote:

> Thanks so much for the elaborate and pertinent answer Ken. You are right. I was not passing the arguments correctly to the task.

You're welcome.  Glad I could help.

> I was creating the arguments like this:
>
>    [args addObject:[NSString stringWithFormat:@"-f \"%@\"", [[sourceDirectoryURL path] stringByAppendingPathComponent:sourceFileName]]];
>
> Whereas, I now understand (hopefully correctly), I should have been creating them like this:
>
>    [args addObject:[NSString stringWithFormat:@"-f%@", [[sourceDirectoryURL path] stringByAppendingPathComponent:sourceFileName]]];

> Yes. Now that I pass the option's identifier with its parameter appended snugly to it (without quotes and separating space char) the URL is created correctly.


Well, that works, but I want to clarify something...

If, in a shell, you were to invoke a command like:

/path/to/some/command -f /path/to/file

Then the program would receive "-f" and "/path/to/file" as separate arguments.  To achieve the same thing with NSTask, you'd pass @"-f" and @"/path/to/file" as two separate elements of the argument array.

You've now switched to the equivalent of:

/path/to/some/command -f/path/to/file

That works in this case, but relies on the program you're invoking parsing apart the option switch from its value.  Apparently, that assumption holds for the program in question.  I just wanted to make sure you understood how to replicate the original form using NSTask.

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem getting correct file URL in NSTask process
      • From: Antonio Nunes <email@hidden>
References: 
 >Problem getting correct file URL in NSTask process (From: Antonio Nunes <email@hidden>)
 >Re: Problem getting correct file URL in NSTask process (From: Ken Thomases <email@hidden>)
 >Re: Problem getting correct file URL in NSTask process (From: Antonio Nunes <email@hidden>)

  • Prev by Date: Re: Logging in ad-hoc builds
  • Next by Date: Re: Problem getting correct file URL in NSTask process
  • Previous by thread: Re: Problem getting correct file URL in NSTask process
  • Next by thread: Re: Problem getting correct file URL in NSTask process
  • Index(es):
    • Date
    • Thread