I'm just speculating:
I think that the variable defined in the ivars allocates the space right in the object. This prevents you from creating accessors because you can't give an array by value to a function but only through a pointer. Therefore you have to use a pointer in the ivars:
int *doubleDigits;
And then allocate the space for it in the init-method:
@synthesize doubleDigits;
- (id)init {
if (self = [super init]) {
doubleDigits = malloc(sizeof(int) * 10);
/*
* This works, but is dangerous (forbidden) because bufferDoubleDigits
* gets deleted at the end of -(id)init because it's on the stack:
* int bufferDoubleDigits[] = {1,2,3,4,5,6,7,8,9,10};
* [self setDoubleDigits:bufferDoubleDigits];
*
* If you want to be on the safe side use memcpy() (needs #include <string.h>)
* doubleDigits = malloc(sizeof(int) * 10);
* int bufferDoubleDigits[] = {1,2,3,4,5,6,7,8,9,10};
* memcpy(doubleDigits, bufferDoubleDigits, sizeof(int) * 10);
*/
}
return self;
}
- (void)dealloc {
free(doubleDigits);
[super dealloc];
}
In this case the interface looks like this:
@interface MyClass : NSObject {
int *doubleDigits;
}
@property int *doubleDigits;
Edit:
I'm really unsure wether it's allowed to do this, are those values really on the stack or are they stored somewhere else? They are probably stored on the stack and therefore not safe to use in this context. (See the question on initializer lists)
int bufferDoubleDigits[] = {1,2,3,4,5,6,7,8,9,10};
[self setDoubleDigits:bufferDoubleDigits];