셀의 값을 저장하는 NSMutableArray
(아마도 NSIntegers
)을 유지해야합니다. 그런 다음 사용자가 값을 변경할 때마다 배열의 값을 업데이트하십시오. 또한 배열에서 읽음으로써 셀 레이블 값을 표시하십시오. 아래 샘플 코드 -
-(void)plusButtonClicked:(id)sender
{
//figure out the cell index which was updated using sender
//update the array entry
//[self.array objectAtIndex:index]++; self.array is the array you will maintain
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.label.text = [NSString stringWithFormat: @"%d", [self.array objectAtIndex:indexPath.row]];
}
앱을 종료하고 다시 시작한 후에도 값을 유지하려면 CoreData를 사용하는 것이 좋습니다.
코어 데이터를 사용하여 테이블 뷰의 상태를 저장하는 방법에 대한 좋은 자습서를 알고 계십니까? 나는 수색했고 나는 도움이되는 것을 발견 할 수 없었다! 도와 주셔서 감사합니다! – iProRage