NSArray在GNUstep下的用法

 

 

  1. #include "say.h" 
  2. #include <Foundation/Foundation.h> 
  3.  
  4. int main(void)  
  5.         id speaker; 
  6.         NSString *name = @"GNUstep !"
  7.         NSAutoreleasePool *pool; 
  8.         NSArray           *outArray; 
  9.          
  10.         pool = [NSAutoreleasePool new]; 
  11.         speaker = [[Say alloc] init]; 
  12.         outArray = [[NSArray alloc] initWithObjects: @"Msg1", @"Msg2", @"Msg3", @"Msg4", nil]; 
  13.         //printf("%@\n", [outArray objectAtIndex: 0]);      //GNUstep下只输出了@ 
  14.         //GSPrintf(stdout, "%@", [outArray objectAtIndex: 1]);  // GNUstep下崩溃 
  15.         NSLog(@"%@\n", [outArray objectAtIndex: 2]);                        // GNUStep下ok 
  16.          
  17.         [speaker sayHello]; 
  18.         [speaker sayHelloTo: name]; 
  19.          
  20.         RELEASE(speaker); 
  21.         RELEASE(pool); 
  22.          
  23.         #ifdef DEBUG 
  24.             NSLog(@"%@\n", @"Debug Now"); 
  25.         #endif 
  26.          
  27.         return 0;