通过uint8_t有数组方法 [英] Pass uint8_t array to method
本文介绍了通过uint8_t有数组方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有四个 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 };
我已经将它们添加到数组:
I have added them to array:
uint8_t *theArray[] = { arrayOne,arrayTwo,arrayThree,arrayFour };
现在我想这个数组传递给方法,例如:
now I want to pass this array to a method, for example:
[self theMethod:theArray];
到
-(void)theMethod:(uint8_t *)pointersArray[]{
...
...
}
什么是指在阵列的方法的正确方法 - (无效)theMethod ...
推荐答案
这行:
uint8_t *theArray = { arrayOne,arrayTwo,arrayThree,arrayFour };
实际上是创建与在指针数组的填充一个数组转换为uint8_t有值。我不认为这是你想要的。
is actually creating an array filled in with the pointers to your arrays converted to uint8_t values. I don't think this is what you want.
所以首先(注意双指针):
So first of all (notice the double pointer):
uint8_t *theArray[] = { arrayOne,arrayTwo,arrayThree,arrayFour };
那么你的ObjC方法变为:
Then your ObjC method becomes:
-(void)theMethod:(uint8_t **)pointersArray {
}
这篇关于通过uint8_t有数组方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文