views:

154

answers:

1

Ok, so I have this singleton object and in it is an array that needs to be shown in a tableview. The thing is that it deallocates and after the first show, i get EXC_BAD_ACCESS in cellForRowAtIndexPath

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 return [[dataBase shareddataBase].dateActive count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"celula"];
 int i;
 i=indexPath.row;
 if (cell==nil) {
  cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"celula"];
 }

count sent to dealocated instance of CFArray .. in cellForRowAtIndexPath.. WHAT is deallocating it? why? it's declarea as an NSMutableArray and has a (nonatomic,retain) property defined ..

 if ((i<[[dataBase shareddataBase].dateActive count])&&(i>=0)) {
  NSDictionary *d=[[dataBase shareddataBase].dateActive objectAtIndex:i];
  cell.textLabel.text=[d objectForKey:@"detaliu"];
 }


  return cell;
}
A: 

Most likely you never retained shareddatabase when you set it.

Jared P
What do you mean retain it?It's a singleton. Aren't those thing in memory all the time? I read that a singleton is created on fist access and requires no retaining and will exist for the duration of the program. Where do I retain it?
http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.htmlI'm using this guys singletonheader to create the shareddataBase object..