title: Obj-C send and receive array over tcp sockets for iphone.
body: <p>I am trying to figure to figure out how and if you can send and recieve arrays over TCP socket. I am a bit of a newbie at objective C but I have been able to send and receive strings. I just want to get it to do arrays now. </p>
  
  <pre><code> (void)stream:(NSStream *)theStream handleEvent:(NSStreamEvent)streamEvent {
  
  NSLog(@"stream event %i", streamEvent);
  
  switch (streamEvent) {
  
      case NSStreamEventOpenCompleted:
          NSLog(@"Stream opened");
          break;
      case NSStreamEventHasBytesAvailable:
  
          if (theStream == inputStream) {
  
              uint8_t buffer[1024];
              int len;
  
              while ([inputStream hasBytesAvailable]) {
                  len = [inputStream read:buffer maxLength:sizeof(buffer)];
                  if (len &gt; 0) {
                      output = [[NSString alloc] initWithBytes:buffer length:len encoding:NSASCIIStringEncoding];
  
                      if (nil != output) {
  
  
  
                          chSent = [output substringWithRange: NSMakeRange (0, 6)];
  
                          dimensionString = [output substringWithRange: NSMakeRange (7, 3)];
                          colorString = [output substringWithRange: NSMakeRange (7, 3)];
  
  
                           if ([chSent isEqualToString:@"dimen:"])
                          {
  
                              dimensionInt = [dimensionString intValue];
  
                          }
  
                          if ([chSent isEqualToString:@"color:"]) {
  
                             // insert array named color in here some how
  
                          }                                
  
  
                      }
                  }
              }
          }
          break;
  
  
      case NSStreamEventErrorOccurred:
  
          NSLog(@"Can not connect to the host!");
          break;
  
      case NSStreamEventEndEncountered:
  
          [theStream close];
          [theStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
         // [theStream release];
          theStream = nil;
  
          break;
      default:
          NSLog(@"Unknown event");
  }
   }
  </code></pre>
  
  <p>Thats what I have. 
  where I have put // insert array is where I am trying to put it </p>
  
  <p>Thanks in advance if you can help. </p>