home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / AlexNeXTSTEPSource / Source / Chapter2_ObjC / Sample / Sample.m < prev   
Encoding:
Text File  |  1993-03-25  |  912 b   |  39 lines

  1. // import the header files for all the classes
  2. // which we will be using: appkit.h contains
  3. // the header files for all the classes
  4.  
  5. #import <appkit/appkit.h>
  6.  
  7. // minimal Obj-C program to insert some objects
  8. // into a list
  9.  
  10. main()
  11. {
  12.     // declare the objects
  13.     id theList, aSampleObject;
  14.  
  15.     // instantiate the List class using alloc
  16.     // and initialize the list using init
  17.     theList = [[List alloc] init];
  18.  
  19.     // create an object
  20.     aSampleObject = [[Object alloc] init];
  21.  
  22.     // insert the objects into the list;
  23.     [theList addObject:aSampleObject];
  24.  
  25.     // print how many objects are in the list
  26.     printf("There are %d object(s) in the list\n",
  27.         [theList count]);
  28.     
  29.     // demonstrate polymorphism by sending the
  30.     // name method to theList and aSampleObject
  31.     printf("theList is an instance of %s\n",
  32.         [theList name]);
  33.     printf("aSampleObject is an instance of %s\n",
  34.         [aSampleObject name]);
  35.  
  36.     // exit the application
  37.     exit(0);
  38. }
  39.