如何将Table View单元格数据复制到NSMutableArray?

时间:2011-06-29 05:54:18

标签: iphone objective-c ios uitableview nsmutablearray

我对iphone开发很新。我使用coredata创建了待办事项列表应用程序。所以,我的表视图动态更新。 我想将表视图行textlabels添加到NSMutable数组(这意味着row1文本标签到MutableArray的第一个索引位置,row2文本标签到Array的第二个索引位置)

这是我的表视图cellfor indexpath方法

- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *HeroTableViewCell = @"HeroTableViewCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:HeroTableViewCell];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:HeroTableViewCell] autorelease];
}
NSManagedObject *oneHero = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSInteger tab = [tabBar.items indexOfObject:tabBar.selectedItem];
switch (tab) {
    case kByName:
        cell.textLabel.text = [oneHero valueForKey:@"name"];
        cell.detailTextLabel.text = [oneHero valueForKey:@"secretIdentity"];
        break;
    case kBySecretIdentity:
        cell.detailTextLabel.text = [oneHero valueForKey:@"name"];
        cell.textLabel.text = [oneHero valueForKey:@"secretIdentity"];
    default:
        break;
}
//listData = [[[NSMutableArray alloc] init]autorelease];
//if(indexPath.row==1){
    //[listData addObject: cell.textLabel.text];
return cell;

}

评论说明了我是如何尝试的,但我正在努力按照自己的意愿去做 请帮我 。 。

0 个答案:

没有答案
相关问题