While walking through the sample code application for the iPhone, I found a couple of send and receive methods that actually had the same signature definitions, except for the value types associated with one of the variables.
Inside the header:
- (void)receivedData: (unsigned char *)data length:(NSUInteger)len;
- (void)sendData: (uint8_t*) data length:(NSUInteger) len;
These methods are used as wrappers for the send / receive process, which effectively passes a pointer to an array of bytedata written to and from data streams. I found these method signatures a little curious, and since I'm new to Cocoa / Cocoa Touch dev, I decided to check the type definition uint8_t. I found that it uint8_tis defined as unsigned charinternally stdint.h, and so the variables datafor these methods are exactly the same. At least this applies to stdint.hwhich is connected in Xcode 4.2.
However, after doing some further research regarding type uint8_t, I found this question regarding usage uint8_tvs. unsigned char. The consensus seems to be that often these two types of values are exactly the same, but with some implementations of the standard C libraries they can be different. Ergo, you should not believe that they will be the same data type when creating portable code.
With that said, can it be assumed that, within the framework of the Apple / Objective-C programming environment, the value uint8_twill be the same as unsigned char, or should I follow the same advice mentioned in the above question?
, , , , -, , Apple ( ), .