I need something like this:
@property (nonatomic, retain) int field[10][10];
but this code doesn't work. How to replace it? I need both setter and getter methods
You can do it if you wrap the array in a struct. Structs are supported in @property notation (see CGRect bounds on CALayer, for example).
First define your struct:
typedef struct {
int contents[10][10];
} TenByTenMatrix;
Then, in your class interface, you can do:
@property (assign) TenByTenMatrix field;
Note that in this case, you can only get or set the whole array using the property. So you can't do
self.field.contents[0][0] = 1;
You'd have to do
TenByTenMatrix temp = self.field;
temp.contents[0][0] = 1;
self.field = temp;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With