Question

I get the warning

Incompatable ponter type 'uint8_t *' send to 'uint8_t **'

when passing value to parameter 'buffer' in below method in NSStream class

- (BOOL)getBuffer:(uint8_t **)buffer length:(NSUInteger *)len;

Below is the code I am using. 'fileStream' is 'NSInputStream' instant object

    uint8_t oneByte;
[fileStream read: &oneByte maxLength: 1];
NSUInteger* remaining = 0;
[fileStream getBuffer: &oneByte length:remaining];
Was it helpful?

Solution

It appears from the signature that the method does not want you to allocate space for the buffer, or pass the length: it will return a pointer to an existing buffer, and set the length of that buffer to the NSUInteger pointer that you pass, like this:

uint8_t *buf;
NSUInteger len;
[fileStream getBuffer:&buf length:&len];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top