Hello all! I'm new to objective-C. I want to use NSMutableArray to store some objects i will access later.
I've got the interface:
@interface ControlWheel : RotatableObject <LeverSubject>
{
NSMutableArray *subjectArray_;
}
-(id) initWithCWDef: (ControlWheelDef*) def;
-(void) addSubject: (id) subject;
@end
Here is the implementation:
-(id) initWithCWDef:(ControlWheelDef *)def
{
...
self = [super initWithDef:&rDef];
if (self)
{
subjectArray_ = [NSMutableArray arrayWithCapacity:1];
}
return self;
}
-(void) addSubject:(id)subject
{
[subjectArray_ addObject:subject];
}
-(void) angleChangeCallback
{
unsigned int count = [subjectArray_ count];
for (unsigned int i = 0; i < count; i++)
{
[[subjectArray_ objectAtIndex:i] onAngleChanged:angle_];
}
}
The problem is in angleChangeCallback function. subjectArray_ is out of scope. What i'm doing wrong?