Reputation:
I have a function that has an array pointer passed it to modify stuff in an array:
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
Thanks in advance!
Upvotes: 4
Views: 3828
Reputation: 28250
It looks like you're using the plain C array. Remember that array pointers are simply pointers to the first element in the array. You don't pass the "whole array" as a reference, you'll just pass the pointer at index 0.
If you're passing the array, you should define your parameter as a pointer, Byte*
, because that's what it really is when you pass a simple C array.
Upvotes: 1
Reputation: 60528
if it's a plain-old array, I would just do this:
(void)arrayFunction:(Byte*)targetarray
Or, to be more "OO-ish", use NSData instead of a byte array:
(void)arrayFunction:(NSData*)targetarray
Upvotes: 5