我對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