Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hassoon

macrumors regular
Original poster
Jun 8, 2009
154
0
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.
 
Last edited:

robvas

macrumors 68040
Mar 29, 2009
3,240
629
USA
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;
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.