私は多くの投稿を調べましたが、これを解決する方法がまだわかりません。誰かが助けてくれることを願っています。
最後のデータソースメソッドであるcellForRowに到達するまで機能します。その時点で、セクションごとに正しいNSSetを取得できますが、順序付けされていません。リレーションシッププロパティへのイントロペクションは行に対してどのように機能しますか?
cellForRowで文字列リテラルを使用すると、各セクションで正しい行数を取得できますが、そこにある管理対象オブジェクトへの接続は明らかにありません。
NSSetリレーションシップから行を設定するにはどうすればよいですか?すべての洞察に感謝
カテゴリ<<--->> Person
cName ---------- pName
人間関係の
人々----------カテゴリ
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [[self.fetchedResultsController fetchedObjects] count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
Category* cat = [[self.fetchedResultsController fetchedObjects] objectAtIndex:section];
return [[cat people] count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
Category* cat = [[self.fetchedResultsController fetchedObjects] objectAtIndex:section];
NSNumber *rowCount = [NSNumber numberWithUnsignedInteger:[[cat people] count]];
return cat.cName;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSManagedObject *mo = [[fetchedResultsController fetchedObjects] objectAtIndex:index.row]];
// returns the correct set but unordered, possibly work with this to populate the rows?
//NSSet *theSet = [[NSSet alloc] initWithSet: [mo valueForKeyPath:@"people.pName"]];
// doesn't work
// cell.textLabel.text = [NSString stringWithFormat:@"%@",[mo valueForKeyPath:@"people.pName"]];
cell.textLabel.text = @"something";
return cell;
}