Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6966903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:15:07+00:00 2026-05-27T16:15:07+00:00

I am new to Cocoa and Xcode, but I really do want to learn.

  • 0

I am new to Cocoa and Xcode, but I really do want to learn. The problem is that I spend a lot of my time doing work in scripting languages like PHP, perl, python, and shell scripting, and while Cocoa is a lot more powerful than running a shell script in Terminal on OS X, it is also a bit harder to get into.

I have a hypothesis though: If I can start using Cocoa and Xcode to actually do some things then I’ll get more comfortable with it and gradually start to unlock more and more of it’s potential.

That’s where I hope StackOverflow comes in. See, I’m used to writing scripts that take paramaters (mostly file names) as inputs, and act on them – either dispatching other programs or reading and writing to the text-based contents. So with that in mind, How can I write a simple Cocoa application that will accept input, save that input to a file, and launch a system command?

Desired input:

open -a MyApp.app --args "hello world"

Desired output:

  • File /tmp/test.txt is created and now contains text hello world
  • The php version is checked by running /usr/bin/php -v and the output is then appended to /tmp/test.txt (just wanted to call some system command)

I know this sort of thing is very easy to do with just 1-2 lines of something like bash scripting, but I’d really like to see if I could make this happen in a Cocoa app. I apologize in advance because I realize this is very much a noob question – just trying to get started in a way that feels familiar.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:15:08+00:00Added an answer on May 27, 2026 at 4:15 pm

    If you want to process command-line arguments and have a GUI, you’ll definitely want to look at NSProcessInfo. Among other things, it has a method called arguments that returns the command-line args as an NSArray.

    It can also give you an NSDictionary of environment variables, which can also be really useful, from the environment method.

    Edit: I forgot to mention, if you want to save the contents of a string to file, NSString already has a method for that! Look at the docs for writeToFile:atomically:encoding:error:.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a complete Xcode/Objective-C/Cocoa newbie but I'm learning fast and really starting to enjoy
I'm pretty new to cocoa and Xcode, I've done some basic C coding, but
I'm new to Cocoa and xCode, but not programming though. I have created some
I'm new to Cocoa development - I want to display an aribitrary number of
I'm very new to Cocoa for MacOSX, but I can't help but feel like
I am new to Cocoa, but managed to get a connection (to a FTP)
I'm new to Objective-C and Cocoa. I've read that NSInteger and NSNumber are preferred
I created a new project in Xcode 4 using the Cocoa Application template and
1. Step: Create a new UIViewController: - Xcode -> New File... -> Cocoa Touch
I am relatively new to Cocoa/Xcode and am not sure if I am structuring

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.