PRelation
カテゴリと、カテゴリにアイテムをPFQueryTableViewController
追加するために使用するアイテムを作成しようとしています。すべてのPFQueryTableViewController
アイテムが一覧表示され、ユーザーはカテゴリに入れるアイテムを選択します。私が理解しようとしているのは、アイテムがカテゴリに含まれているかどうかを判断し、PFTableViewCell
accessoryTypeをに設定する方法だけです。UITableViewCellAccessoryCheckmark
現在のコード:
- (PFTableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
static NSString * CellIdentifier = @"Cell";
BOOL itemInCategory = ?; //This is where I am determining the hierarchy
PFTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.textLabel.text = [sendingObject valueForKey:@"Title"];
cell.accessoryType = itemInCategory ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return cell;
}
編集
カテゴリからアイテムを削除するためのサポートも必要です。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
BOOL itemInCategory = ?;
if (itemInCategory) {
//Remove Item?
} else {
PFRelation * relation = [sendingObject relationforKey:@"Items"];
[relation addObject:[self.objects objectAtIndex:[indexPath row]]];
[self save];
}
}
かなりシンプルなはずです
乾杯