我对iphone的开发很陌生。我使用coredata创建了待办事项列表应用程序。所以,我的表视图动态更新。 我想表视图行textlabels添加至NSMutable阵列(这意味着ROW1文本标签MutableArray的第一转位位置,ROW2文本标签阵列的第二索引位置)如何将TableView单元格数据复制到NSMutable阵列?
这是我的表视图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;
}
评论行是我如何做到这一点。但我很努力地添加这些数据。 请帮我
好像你已经得到它 - 数据应该来自阵列并复制到表单元格。你能编辑你的问题来解释你想完成什么吗? – Caleb
您已经从核心数据中检索对象。为什么需要将这些单元格中的数据复制到另一个数组中? –
你可以直接从coredata(tableview datasource)获取并传递给一个数组no ?? http://mobile.tutsplus.com/tutorials/iphone/iphone-core-data/在这个链接检查timetablecontroller.m代码 – sujith1406