14
Jul
Come to/Login to the Mac OS-X shell prompt via the Terminal application or via SSH from a remote client. In the example I have used nano text editor to create these Objective C files using the Cocoa foundation framework
File: hello.h#include <Foundation/Foundation.h> @interface Hello: NSObject { } - (void) sayHelloTo: (NSString *)name; @endFile: hello.m
#include <Foundation/Foundation.h> #include "hello.h" @implementation Hello - (void) sayHelloTo: (NSString *)name { NSLog(@"Hello World, %@", name); } @endFile: main.m
#include <Foundation/Foundation.h> #include "hello.h" int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; id speaker; NSString *name = @"GNUstep ... Sree"; speaker = [[Hello alloc] init]; [speaker sayHelloTo:name]; [speaker release]; [pool drain]; return 0; }Command to compile:
gcc -framework Foundation main.m hello.m -o helloCommand to run:
./helloOutput:
2010-07-14 15:57:39.459 hello[5325:903] Hello World, GNUstep ... Sree




