Suppose there is a class:
@interface FooBar : NSObject
@property(readonly, getter = _getSpace) int** space;
@end
The space property is implemented as follows:
@implementation FooBar
int m_space1[256];
int m_space2[256];
int* m_space[2] = { m_space1, m_space2};
-(int **) _getSpace {
return m_space;
}
@end
Is it then legal to alter the int[2][256] array using:
FooBar * f = [[FooBar alloc] init];
f.space[1][120] = 0;
?
Yes. You’re returning a pointer, and then modifying a value that’s being pointed to. This is perfectly legitimate. If you don’t want to allow this then you need to add the appropriate const modifiers to the type.
What’s not legitimate is returning a struct and modifying that struct directly.
As KennyTM mentioned in the comments, your
m_space{,1,2}variables are global variables rather than, as you probably intended, instance variables. The simplest way to fix this is to just put an ivar block in your@implementation, as in