My NSMutableArray doesn't store any object, either a String or a complex class. I tried it to allocate ind init and to init as an array. Both without success.
.m file:
@interface WorkCentersViewController()
@property (nonatomic, retain) NSMutableArray *selectedWorkCenters;
@end
@implementation WorkCentersViewController
@synthesize selectedWorkCenters;
-(id)init{
self = [super init];
if(self){
//self.selectedWorkCenters = [[NSMutableArray alloc] init]; //doesn't work too
self.selectedWorkCenters = [NSMutableArray array];
}
return self;
}
- (void)dealloc
{
[selectedWorkCenters release];
[super dealloc];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if(cell.accessoryType == UITableViewCellAccessoryCheckmark){
...
}else{
//select
cell.accessoryType = UITableViewCellAccessoryCheckmark;
//add
[self.selectedWorkCenters addObject:[self.workCenters objectAtIndex:indexPath.row]];
NSLog(@"Sel WC Count: %d", [self.selectedWorkCenters count]); //always 0
}
}
Why is it not storing my object of WorkCenter? What I'm doing wrong?
BR, mybecks