Если вы заключите свой массив в структуру, он станет назначаемым.
typedef struct
{
CGFloat c[8];
} Components;
// declare and initialise in one go:
Components comps = {
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.15
};
// declare and then assign:
Components comps;
comps = (Components){
0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.15
};
// To access elements:
comps.c[3] = 0.04;
Если вы используете этот подход, вы также можете возвращать Components
структуры из методов, что означает, что вы можете создавать функции для инициализации и присвоения структуре, например:
Components comps = SomeFunction(inputData);
DoSomethingWithComponents(comps);
comps = GetSomeOtherComps(moreInput);
// etc.