I'm trying to initialize an NSMutableArray and it's not working correctly. Subsequent access to the array throws an exception saying "index 0 beyond bounds for empty array." A breakpoint following the initialization line says that my array has a location in memory, but that it has 0 objects
Here's my attempt at the moment:
in my .h
@interface SomeInterface : NSObject
{
@private
NSMutableArray *myArr;
}
in my .m
- (id) initWithHeight: (int) height
{
self = [super init];
if (self)
{
self->myArr = [[NSMutableArray alloc] initWithCapacity:height];
}
return self;
}
The breakpoint shows myArr = (NSMutableArray *) 0x######## 0 objects
Does anyone know how to properly initialize an NSMutableArray?