In an NSObject subclass declaration is an array:
@interface theClass : NSObject {
NSMutableArray *myArray;
}
...
@end
In the implementation’s initializer:
- (id)init
{
self = [super init];
if (self) {
[myArray initWithCapacity:50];
}
return self;
}
And in a method:
- (NSMutableArray *)theMethod:(NSArray *)someArray {
...
...
[myArray addObject:anObject];
...
return myArray;
}
Yet despite the class being instantiated in my controller, any number of messages to the method leave myArray without contents.
You haven’t allocated the array yet. Replace your
initcode with the following: