If you find this article useful, consider making a small donation to show your support for this web site and its content.
Free app Developer Interview available here.

Available on the iPhone App Store
Available on the Google Play
AboutMe
About me:
Hi. My name is Farooq Kaiser and I'm a software developer from Toronto, Canada.



iphone Hello World in Objective C

by Farooq Kaiser 28. June 2009 03:45
As i have mentioned in my previouse article that All iPhone development is done in objective-c. 
Today i will start with a simple program using command line.

$ cat helloworld.h
 
1- #import <Foundation/Foundation.h>  
 
2- int main (int argc, const char *argv[])
3- {
4-      NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
5-      NSLog (@"Hello World!");
6-      [pool drain];
7-      return 0;
8- }
  
compiling and running:
 
$ gcc -framework Foundation helloworld.m
$ ./a.out
 
Hello World!
 
Now we will understand the above code. Line numbers are for reference.  

Line 1 include the base class 

Line 4 declared for memory management. Reserves space in memory.

Line 5 NSLog is a function that displays the argument you pass in.

Line 6 Release the allocated memory pool

Line 7 Terminate the execution of main.  

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

iphone | Objective-C


comments powered by Disqus

Comments

Jobs Autos Real estate Videos Power by Google