私は頭の中で考えを持っていますが、これは最善の解決策ではないかもしれません。bool属性に基づいて、「isShared」、「notShared」、および「completed」のオブジェクトを含む3つの配列を作成できますか?
次に、テーブルビューセルメソッドで
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//Custom your cell for different section here
switch (indexPath.section)
{
//First section is shared item
case 0:
if(cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
//Custom your cell here, for example, you can assign an item in your list to the cell's textlable
cell.textLabel.text = [sharedArray objectAtIndex:[indexPath row]];
}
break;
case 1:
if(cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
//Custom your cell for not shared item here
cell.textLabel.text = [notSharedArray objectAtIndex:[indexPath row]];
}
break;
case 2:
if(cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
//Custom your cell for not shared item here
cell.textLabel.text = [CompletedArray objectAtIndex:[indexPath row]];
}
break;
default:
break;
}
return cell;
}
したがって、bool属性でグループ化された3つのセクションがテーブルビューに表示されます。リスト内の1つのアイテムを変更する場合、つまり、非共有セクションから1つの非共有アイテムを共有する場合は、そのオブジェクトをunSharedArrayからsharedArrayに移動するメソッドを実装してから、を呼び出す必要があります。
[tableView reloadData]
テーブルビューを更新します。