セルの値を保存する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