how to convert byte value into int in objective-c

后端 未结 5 1199
感动是毒
感动是毒 2021-01-01 06:24

Please tell me how to convert bytes to NSInteger/int in objective-c in iPhone programming?

5条回答
  •  粉色の甜心
    2021-01-01 06:39

    If by byte, you mean an unsigned 8 bit value, the following will do.

    uint8_t foo = 3;   // or unsigned char foo...
    NSInteger bar = (NSInteger) foo;
    

    or even

    NSInteger bar = foo;
    

提交回复
热议问题