我有四个uint8_t
数组:
uint8_t arrayOne[12] = { 0x00,0x01,0x00,0x00,0x00,0x06,0xFE,0x03,0x01,0xC1,0x00,0x01 };
uint8_t arrayTwo[12] = { 0x00,0x01,0x00,0x00,0x00,0x06,0xFE,0x03,0x4E,0x2D,0x00,0x0C };
uint8_t arrayThree[12] = { 0x00,0x01,0x00,0x00,0x00,0x06,0xFE,0x03,0x01,0xF3,0x00,0x01 };
uint8_t arrayFour[12] = { 0x00,0x01,0x00,0x00,0x00,0x06,0xFE,0x03,0x20,0x04,0x00,0x01 };
我已将它们添加到数组中:
uint8_t *theArray[] = { arrayOne,arrayTwo,arrayThree,arrayFour };
现在我想将此数组传递给方法,例如:
[self theMethod:theArray];
为:
-(void)theMethod:(uint8_t *)pointersArray[]{
...
...
}
将数组指向某个方法的正确方法是什么 - (void)theMethod ...?
答案 0 :(得分:1)
这一行:
uint8_t *theArray = { arrayOne,arrayTwo,arrayThree,arrayFour };
实际上是创建一个数组,其中包含转换为uint8_t 值的数组的指针。我不认为这是你想要的。
首先(注意双指针):
uint8_t *theArray[] = { arrayOne,arrayTwo,arrayThree,arrayFour };
然后你的ObjC方法变为:
-(void)theMethod:(uint8_t **)pointersArray {
}
答案 1 :(得分:0)
声明您的方法以获取指向数组指针的指针
-(void)theMethod:(uint8_t **)pointersArray{
...
...
}
通过像
这样传递方法来调用方法[self theMethod:&theArray];