I'm creating an NSInputStream from an NSData object but once created the stream reports NO for hasBytesAvailable:
NSData* data = [outputStream propertyForKey: NSStreamDataWrittenToMemoryStreamKey];
NSLog(@"creating stream with data 0x%x length %d", [data bytes], [data length]);
NSInputStream *insrm = [[NSInputStream alloc] initWithData:data];
[insrm open];
uint8_t* buf = NULL;
NSUInteger len;
BOOL result = [insrm getBuffer:&buf length:&len];
BOOL hasbytes = [insrm hasBytesAvailable];
NSLog(@"getBuffer:%d hasBytes:%d", result, hasbytes);
NSLog(@"created inputstream data %d len %d", buf, len);
Log:
[26797:20b] creating stream with data 0x7050000 length 34672
[26797:20b] getBuffer:0 hasBytes:0
[26797:20b] created inputstream data 0 len 0
What am I missing here?