简体   繁体   中英

Converting integer from 0 to 255 ( 1 byte ) into NSDATA

对于某种基于套接字的应用程序,我只需要1个字节,我找不到创建它的方法。

unsigned char mydata = 3;
[NSMutableData dataWithBytes:&mydata length:sizeof(mydata)];

NSData reference , unsigned char is used to save 1 byte.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM