Quote:
Originally Posted by exorcyze
Code:
// in your .h
@interface MyListClass : NSObject {
NSArray *list;
}
@property (nonatomic, retain) NSArray *list;
// in your .m
@synthesize list;
- (void) dealloc {[list release];
[super dealloc];
}
// whereever you set it up ( init most likely ):
NSArray *temp = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:1], [NSNumber numberWithInt:2], [NSNumber numberWithInt:3], nil];
self.list = temp;
[temp release];
|
There is no need to create an array of NSNumber objects if you only want integer values.
Code:
// in your .h
@interface MyListClass : NSObject {
const int *list;
}
@end
// in your .m
@implementation MyListClass
static const int constList[5] = {1, 2, 3, 4, 5};
...and in init:
list = constList;
@end