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

时间:2011-06-29 10:33:54

标签: iphone objective-c ios uitableview nsmutablearray

我对iphone开发很新。我使用coredata创建了待办事项列表应用程序。 我想将“oneHero”manageObject中的所有名称添加到NSMutable数组(这意味着Mut1Aray的name1到第一个索引位置,name2到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: [oneHero valueForKey:@"secretIdentity"]];

 return cell;
}

实际上我想要做的是,从我的“oneHero”对象中检索所有名称(这些是位置名称),然后在mapView中显示这些位置。这就是为什么我要将这些名称复制到单独的NSMutable数组或者只是作为字符串
你能给我一个帮助吗? 。 。

0 个答案:

没有答案
相关问题