フェッチされたプロパティは機能します。実際、「日付追加インデックス」でソートする必要がある Post->Comment 関係を持つ自分のプロジェクトでそれを使用しました。
いくつかの注意事項があります。ビジュアル エディターでは並べ替え記述子を指定できず、コードで指定する必要があります。
私はこのようなものを使用します
// Find the fetched properties, and make them sorted...
for (NSEntityDescription *entity in [_managedObjectModel entities])
{
for (NSPropertyDescription *property in [entity properties])
{
if ([property isKindOfClass:[NSFetchedPropertyDescription class]])
{
NSFetchedPropertyDescription *fetchedProperty = (NSFetchedPropertyDescription *)property;
NSFetchRequest *fetchRequest = [fetchedProperty fetchRequest];
// Only sort by name if the destination entity actually has a "index" field
if ([[[[fetchRequest entity] propertiesByName] allKeys] containsObject:@"index"])
{
NSSortDescriptor *sortByName = [[NSSortDescriptor alloc] initWithKey:@"index"
ascending:YES];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sortByName]];
}
}
}
}
My Post エンティティには、次のように定義された「sortedComments」というフェッチされたプロパティがあります。
post == $FETCH_SOURCE
投稿には対多の「コメント」関係があり、コメントには逆の「投稿」があります
ここでの他の回答とは対照的に:このようなフェッチされたプロパティを使用する利点は、CoreDataがキャッシュを処理し、投稿のコメントとしてキャッシュを無効にすること、または実際にそれらを所有する投稿が変更されることです。