联系客服:400-805-1963

NSArray在GNUstep下的用法
更新:HHH   时间:2023-1-7


 

 

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

 

返回开发技术教程...