TextWrangler Demo

Discussion in 'Mac Programming' started by hassoon, Feb 6, 2012.

  1. hassoon, Feb 6, 2012
    Last edited: Feb 6, 2012

    macrumors regular

    Joined:
    Jun 8, 2009
    #1
    can any one show me how to write the "Hello World" program on textWrangler and running it using the terminal with the objective-c language? i know that i can use xcode and stuff but i just wanna learn how to use TextWrangler. Thank you in advance.
    P.S: if you can provide a step-by-step i'll be more than thankful.
     
  2. macrumors 68000

    Joined:
    Mar 29, 2009
    Location:
    USA
    #2
    Edit your file in TextWranger (name it hello.m). Open up a Terminal, and go to the directory that you saved the file in, and enter the following commands:

    gcc -framework Foundation hello.m -o hello


    Then, to run the program enter the following command:

    ./hello


    You can use the following code for this example, save it as hello.m
    Code:
    #import <Foundation/Foundation.h>
    
    int main(int argc, const char *argv[]) {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
        NSLog(@"Hello world\n");
    
        [pool drain];
        return 0;
    }
    
     

Share This Page