curl, grep, and cut on the iPhone

Discussion in 'iOS Programming' started by dtrimble, Jan 19, 2009.

  1. macrumors member

    Jan 7, 2008
    San Francisco, CA, USA
    Good morning,

    Background: I'm brand new to developing applications on the iPhone, and even to the Mac, more or less. In the 1990s, I did a lot of development on PCs in VB, QB, PDS, and some moderate work in Assembly, and Perl. I know scripting on the Mac reasonably well, and most Web languages, but am new to Objective C and Apple's frameworks and SDKs. I haven't done professional-grade programming since the mid-1990s.

    I'm trying to create a relatively simple iPhone app based on a script I wrote for Mac OS X. It simply fetches a URL, uses grep to find a specific file name referenced in the code and that changes regularly, and then retrieves that specific file name. In this case, it is an image file that updates on a regular basis.

    Right now, I don't want to focus on making my iPhone app all shiny and iPhone-ish. I can learn how to add in the functionality for creating a cover flow view, swiping, navigation, and useful functionality after I get past rewriting the basic script commands into a working set of C code.

    So my question comes down to this: is there an Objective C equivalent to the script commands for curl, grep, and cut that will work with iPhone SDK? I haven't had any luck finding them in Apple's reference documents.

  2. macrumors regular


    Jul 18, 2008
    Yes. You can grab the contents of a URL with NSString stringWithContentsOfURL: . Then you can find the image you're looking for with the Standard C Library regex functions in regex.h . Then you can display the image using a UIWebView or a UIImage.
  3. macrumors member


    Sep 22, 2008
    You can also scan the string using NSScanner. That's a quite easy class for scanning strings for other strings and such.

Share This Page