Am I correctly creating and passing this C array to Objective-C method and referencing it with a property?
I created a C array like this: unsigned char colorComps[] = {2, 3, 22, 55, 9, 1}; which I want to pass to an initializer of an Objective-C object. So I think I have to put the array on the heap: size_t arrayByteSize = numColorCompVals * sizeof(unsigned char); unsigned char *colorCompsHeap = (unsigned char*)malloc(arrayByteSize); Then I have to write my first "stack memory array" to the heap array in for loop: for (int i = 0; i < numColorCompVals; i++) { colorCompsHeap[i] = colorComps[i]; } Side question: Is there a more elegant solution to avoid the for-loop step? And then I pass it to the