What I am doing is
//ClassB.h @property (strong, nonatomic) NSString *name;
and
//ClassA.h @interface ClassA : NSObject +(ClassA*)methodA:(NSData*)data; -(id)initWithData:(NSData*)data; @property (nonatomic, strong) NSMutableArray *arr; @property (nonatomic, strong) RXMLElement *rxmlRoot; @end //ClassA.m @implementation ClassA @synthesize arr; @synthesize rxmlRoot; +(ClassA*)methodA:(NSData*)data { return [[ClassA alloc] initWithData:data]; } -(id)initWithData:(NSData*)data { self = [super init]; if (self) { arr = [NSMutableArray array]; rxmlRoot = [RXMLElement elementFromXMLData:data]; /*****edit : just been added to make codes clear*****/ NSString *node = @"players.player"; [rxmlRoot iterate:node with:^(RXMLElement *e){ ClassB *classB = [[[ClassB alloc] init] autorelease]; [classB setName: [e attribute:@"name"]]; // adding ClassB into arr [arr addObject:classB]; }]; } return self; } @end
So now I am having ClassA object whose arr contains ClassB
Question : later on, when I try to access an particular property of ClassB like
((ClassB*)[classA.arr objectAtIndex:0]).name
and I am getting EXC_BAD_ACCESS at above line..
Please advice me on this issue and how to correct the error. Any comments are welcomed here
Thanks