Programming on Mac OS X -- Learn Object-C Serials (1)
Programming on Mac OS X -- Learn Object-C Serials (1)
Autodesk,Inc. Sun Wentao
1. Reference book:
Programming in Objective-C, by Stephen G. Kochan, October 30, 2003
Cocoa® Programming for Mac® OS X, Third Edition, by Aaron Hillegass, May 05, 2008
2. Ch1 Get started with Object C on Mac OS X
2.1 First simple program in Object C
// First program example
#import <stdio.h>
int main (int argc, const char *argv[])
{
printf ("Programming is fun.\n");
return 0;
}
#import <stdio.h>
int main (int argc, const char *argv[])
{
printf ("Programming is fun.\n");
return 0;
}
Notice for C/C++ programmers:
(1) #import instead of #include in ordinary C++ or C files;
(2) When building this kind of object-c file, *.m, use gcc like this:
gcc filename -o objectname -l objc
(2) When building this kind of object-c file, *.m, use gcc like this:
gcc filename -o objectname -l objc
Option: -l objc means to specify current build language is "object c"