emailconfirmed, nsInternRO, nsInternRW, Administrators
3,356
edits
|  (added NeXTStep Links / translated to english) |  (→Hello World:  new example) | ||
| Line 1: | Line 1: | ||
| == Hello World == | == Hello World (new ARC enabled example) == | ||
| Xcode, Interface Builder und Co. are very powerful tools, but sometimes they seem to make things a little bit more complicated than they really are. Here's a short program in Objective-C: | |||
| <source lang="objc"> | |||
| #import <Foundation/Foundation.h> | |||
| int main (int argc, const char * argv[]) { | |||
|     @autoreleasepool { | |||
| 	// Hello World! | |||
| 	printf("About to print the most important message...\n"); | |||
| 	NSLog(@"Hello World!\n"); | |||
|     } | |||
|     return 0; | |||
| } | |||
| </source> | |||
| You can compile either with a simple Editor that supports this (e.g. [http://macromates.com/ TextMate]: Actions: Run) - or you use the gcc compiler with Bash (Terminal.app): | |||
| <source lang="bash"> | |||
| cd ~/Path/to/HelloWorld.m | |||
| clang HelloWorld.m -o HelloWorld -framework Foundation | |||
| ./HelloWorld | |||
| </source> | |||
| == Hello World (old, non-ARC example) == | |||
| Xcode, Interface Builder und Co. are very powerful tools, but sometimes they seem to make things a little bit more complicated than they really are. Here's a short program in Objective-C: | Xcode, Interface Builder und Co. are very powerful tools, but sometimes they seem to make things a little bit more complicated than they really are. Here's a short program in Objective-C: | ||
| Line 24: | Line 51: | ||
| ./HelloWorld | ./HelloWorld | ||
| </source> | </source> | ||
| == Objective-C Introduction == | == Objective-C Introduction == | ||