You can use a number of methods to overcome this problem, but the easiest is to simply make the instance variable a pointer, like this:
@interface TestClass : NSObject {
int *test;
}
@property int *test;
@end
Synthesizing the property will give it getter and setter methods which you can use to set its contents:
@implementation TestClass
@synthesize test;
//contents of class
@end
You can then use it like this:
TestClass *pointerTest = [[TestClass alloc] init];
int *array = (int *)malloc(sizeof(int) * count);
//set values
[pointerTest setTest:array];
[pointerTest doSomething];
However, using objects like NSNumber in an NSArray is a better way to go, perhaps you could do something like this:
@interface TestClass : NSObject {
NSArray *objectArray;
}
@property (nonatomic, strong) NSArray *objectArray;
@end
@implementation TestClass
@synthesize objectArray;
//contents of class
@end
You can then set its contents with a pointer to an NSArray object:
NSArray *items = [NSArray arrayWithObjects:[NSNumber numberWithInt:1], [NSNumber numberWithInt:2], nil];
TestClass *arrayClass = [[TestClass alloc] init];
[arrayClass setItems:items];
[arrayClass doSomething];
When retaining objects upon setting them (like the previous example), always make sure you deallocate the object in the classes dealloc method.