好像我有完全相同的问题。当我使用 {7,7} 范围时,CFBitVectorGetBits 将我的 *bytes 设置为 nil。找到任何解决方案了吗?我现在通过愚蠢地迭代比特来实现它。
编辑:
添加代码:
CFBitVectorRef source = ... ;// Some source bit vector
CFIndex location = 7;//Current location in bit vector
uint8 *bytes = malloc(sizeof(uint8));
//CFBitVectorGetBits(source, CFRangeMake(location,7), bytes);//This one is bugged
CFBitVectorRef buffer = CFBitVectorCreateMutable(NULL,7);
CFBitVectorSetCount(buffer, 7);
for (CFIndex i=0; i<7; i++)
CFBitVectorSetBitAtIndex(buffer, i, CFBitVectorGetBitAtIndex(source, location+i));
CFBitVectorGetBits(buffer, CFRangeMake(0, 7), bytes);
//Now *bytes contains needed bits
根据需要工作。