Объявите NSMutableArray
член allPreActions
в файле .h (Объявите его как член класса) и заполните его в viewDidLoad
или где-то еще до cellForRowAtIndexPath:
Таким образом, этот код появится в viewDidLoad
PrepopulatedActionsDao * preAction = [[PrepopulatedActionsDao alloc] init];
if( allPreActions )
{
[allPreActions releaseAllObjects];
[allPreActions release];
}
allPreActions = [[preAction getDataFromDatabase] retain];
[preAction release];
А ваш cellForRowAtIndexPath:
будет выглядеть следующим образом
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
Action *actionInformation;
if(cell == nil){
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, 460) reuseIdentifier:@"MyIdentifier"] autorelease];
}
actionInformation=[allPreActions objectAtIndex:indexPath.row];
cell.textLabel.text = [NSString stringWithFormat: @"%@",actionInformation.action];
return cell;
}