title: NSInputStream not opening stream/ How to post data when setting up stream
body: <p>What I am trying to do: I have a url request (post) where I send some information to a api server which then starts streaming data in bytes to me.</p>
  
  <p>1) How do I post data when trying to set up a stream as right now I am just using a url, can I incorporate a <code>NSURLRequest</code> some how? </p>
  
  <p>2) Why isnt my stream even opening (streamStatus returns 0) and thus <code>- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode</code> never being called? , this is my best attempt and for the most part following this <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Streams/Articles/ReadingInputStreams.html#//apple_ref/doc/uid/20002273-BCIJHAGD" rel="nofollow">Guide</a></p>
  
  <pre><code>- (void)setUpStreamFromURL:(NSURL *)path {
  
       // iStream is NSInputStream instance variable
       iStream = [[NSInputStream alloc] initWithURL:path];
       [iStream setDelegate:self];
       [iStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
                     forMode:NSDefaultRunLoopMode];
       [iStream open];
  
       NSLog(@"Stream Open: %lu",[iStream streamStatus]); //return 0
  }
  
  - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
       NSLog(@"Streaming");
       switch(eventCode) {
           case NSStreamEventHasBytesAvailable:
           {
               if(!_data) {
                    _data = [[NSMutableData data] init];
               }
                uint8_t buf[1024];
                unsigned int len = 0;
                len = [(NSInputStream *)stream read:buf maxLength:1024];
                if(len) {
                [_data appendBytes:(const void *)buf length:len];
                NSLog(@"DATA BEING SENT : %@", _data);
                // bytesRead is an instance variable of type NSNumber.
               // [bytesRead setIntValue:[bytesRead intValue]+len]; //getting error that setInt value is not part of NSNumber, and thats true so not sure what to do about it, but this isn't the issue. 
                } else {
                      NSLog(@"no buffer!");
                } 
                break;
           }
           case NSStreamEventEndEncountered:
           {
                [stream close];
                [stream removeFromRunLoop:[NSRunLoop currentRunLoop]
                            forMode:NSDefaultRunLoopMode];
                stream = nil; // stream is ivar, so reinit it
                break;
           }
          // continued ...
       }
  }
  </code></pre>
  
  <p>also incase it helps, my header file:</p>
  
  <pre><code> #import &lt;Foundation/Foundation.h&gt;
   #import "Login.h"
  
   @interface Stream : NSStream &lt;NSStreamDelegate&gt; {
  NSMutableArray *searchIdList;
  NSInputStream *iStream;
  NSNumber *bytesRead;
  
  }
  - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode ;
  -(id)initWithLoginObject:(Login *)log;
  @property NSMutableData *data;
  @end
  </code></pre>