はすでに答えが、他の読者を助けるために一般化する:ここで
//Here: NSData * fileData;
uint8_t * bytePtr = (uint8_t *)[fileData bytes];
// Here, For getting individual bytes from fileData, uint8_t is used.
// You may choose any other data type per your need, eg. uint16, int32, char, uchar, ... .
// Make sure, fileData has atleast number of bytes that a single byte chunk would need. eg. for int32, fileData length must be > 4 bytes. Makes sense ?
// Now, if you want to access whole data (fileData) as an array of uint8_t
NSInteger totalData = [fileData length]/sizeof(uint8_t);
for (int i = 0 ; i < totalData; i ++)
{
NSLog(@"data byte chunk : %x", bytePtr[i]);
}
バイトbyteData = malloc(len); 「初期化すると、キャリブレーションなしでポインタからポインタが生成されます」という警告が表示されます。そして、byteDataはバイト配列ではなく、バイト変数であることが分かります。これについてのアイデアは? –
コードに小さなタイプミスがありました。これは意図したマットとして機能するはずです。 –
はい。 memcpyの第2引数は[data bytes]でなければなりません。 –