如何通过参考一个函数来传递数组中? [英] How to pass an array in by reference to a function?
本文介绍了如何通过参考一个函数来传递数组中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数组的指针传给了修改的东西,在一个阵列功能:
I have a function that has an array pointer passed it to modify stuff in an array:
- (无效)arrayFunction:(字节[])targetarray
{
//做的东西来targetarray
}
这是Byte类型的数组,但我不认为我已经把正确的事全面括号内。它应该是什么,而不是(字节[])?可能有不同的尺寸传递给此函数的若干阵列
It's an array of type Byte, but I don't think that I've put the right thing in the round brackets. What should it be instead of (Byte[])? There may be several arrays of different sizes passed to this function
在此先感谢!
推荐答案
如果它是一个纯旧数组,我只想做到这一点:
if it's a plain-old array, I would just do this:
(void)arrayFunction:(Byte*)targetarray
或者,更OO十岁上下,而不是使用一个字节数组的NSData:
Or, to be more "OO-ish", use NSData instead of a byte array:
(void)arrayFunction:(NSData*)targetarray
这篇关于如何通过参考一个函数来传递数组中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文