How to use c-type array as ivar?

I need a nice old-fashioned 2-dimensional array of integers in my program, but no matter how I try to declare it as ivar and then use @ property / @ synhesize, I get one compiler complaint or the other.

I declare

int spotLocations[10] [10] 

like ivar.

This works, but then the @ property / @ synhesize process never passes.

+3
source share
2 answers

. Array variabless lvalues ​​ C, , , , ( lvalue).

- , . , , .

, , lvalues:

typedef struct {
  int value[10][10];
} matrix;

...

@property matrix spotLocations;

, ,

spotLocations.value[x][y]
+4

, init. @property.

:

spotLocations = malloc(100 * sizeof(int));

:

int aValue = spotLocations[x + y * 10];

() , .

+2

Source: https://habr.com/ru/post/1724516/


All Articles