總結(jié)一下最近在iOS項(xiàng)目中遇到的字節(jié)流相關(guān)知識(shí)。
一、Byte
Byte 是對(duì)字節(jié)的封裝,其類(lèi)型為UInt8,UInt8 又是 unsigned char類(lèi)型。
Byte a = 0x11;
二、Byte *
Byte * 是聲明一個(gè)字節(jié)流指針,初始方法一般用malloc。
Byte * a = malloc(3);
a[0] = 0x11;
a[1] = 0x22;
a[2] = 0x33;
三、Byte[]
Byte[] 是聲明一個(gè)字節(jié)流數(shù)組,并開(kāi)辟一段內(nèi)存,一般用法為:
Byte a[3];
a[0] = 0xff;
a[1] = 0x11;
a[2] = 0xf0;
在Byte * 分配固定的內(nèi)存空間后,用法可等同于Byte[]。即:
Byte * a = malloc(3);
Byte b[3];