Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > question about nstask and arguments

question about nstask and arguments
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 2003
Status: Offline
Reply With Quote
Mar 28, 2003, 03:43 PM
 
I've got a problem with using NSTask and the arguments. The app i'm running with NSTask accepts multiple words separated by a space as its arguments. There can be as many of these words as the user wants. I'm currently getting the user input from a textfield, and then converting it into a string. This string is then added to an array used as the argument for the nstask. The problem is that when the user enters multiple words, there is obviously still only 1 nsstring. However, the console app will take this argument in as only 1, not each word separated. For example, if the user entered "word1 word2" in the text field, the console app would take that entire string as one argument. I need to have it as 2 arguments. Is there anyway to accomplish this?

Thanks for any help
Mike
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Mar 28, 2003, 03:56 PM
 
NSArray args = [string componentsSeparatedByString:@" "];

I'm not sure what this does if you escape out a word...

[@"hello\ world" componentsSeparatedByString:@" "]

This may have unexpected results. You might want to parse around @"\ " first and then do some other work.

Hope this helps,
Matt Fahrenbacher
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:17 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2