I have implemented the following code to assign NSMutableArray to a property –
NSMutableArray * anArray = [responseDictionary valueForKeyPath:@"tags"];
NSLog(@"The array length is=%d",[anArray count]);
for (NSString *s in anArray) {
NSLog(@"you are %@", s);
}
[self setActiveTagArray:anArray];
It prints out the string values fine. But in the setter function, if I place a breakpoint I see that it shows there are two objects but they are “Out of Scope”. What does this mean? What am I doing wrong? My getter also does not fetch any values. The property functions –
-(void)setActiveTagArray:(NSMutableArray *)tags
{
activeTagArray = [[NSMutableArray alloc] init];
activeTagArray = tags;
//NSLog(@"%@",[activeTagArray count]);
}
-(NSMutableArray *)getActiveTagArray
{
return activeTagArray;
}
Is activeTagArray a class variable as well as a property. Consider using _activeTagArray as the class variable name. And then in the .m file just use
@synthesize activeTagArray = _activeTagArray;, and for get the second two methods completely.Response to comment:
You said “I have implemented the following code to assign NSMutableArray to a property”. I took this to mean you have “
@property (nonatomic, retain) NSMutableArray *activeTagArray;” in your .h file. If this is the case then you would access it thruotherObject'sNameForYourClassHere.activeTagArray.@synthesize create accessors & mutators for you.