How create a size_t and how count the size?
-
09-12-2019 - |
Question
I create a NSData and use the function
- (const void *)bytes;
So, it return the bytes in a const void *
variable. If I read the memory manually I will find this:
98 F3 00 76 84 //Then a lot of zero
Use strlen
not work because the 00
. But it will be aways the same size: 10 hexa lenght. So, to create a manually size_t, I will use:
size_t mysize = 0x0A
Or I have use the size in bits:
size_t mysize = 0x28
Is any of this correct?
Solution
The NSData
contains the length.
const void *mybytes = [data bytes];
size_t mysize = [data length];
OTHER TIPS
NSData also has -(NSUInteger)length
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow