奇妙なバグがあります: のコメントを外すNSPredicateと、結果UITableViewは空になります。
私のデータモデルは次のとおりです: カテゴリ <-->> フィード <-->> 投稿
sを取得していPostます。Post.feedです。Post_ プロパティを持っています。FeedFeedrss NString
コードは次のとおりです。
- (NSFetchedResultsController *)fetchedResultsController {
// Set up the fetched results controller if needed.
if (_fetchedResultsController == nil) {
// Create the fetch request for the entity.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Post"
inManagedObjectContext:_globalMOC];
[fetchRequest setEntity:entity];
// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:NO];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
NSPredicate *predicate =[NSPredicate predicateWithFormat:@"feed.rss == %@", _detailItem.rss];
[fetchRequest setPredicate:predicate];
// Edit the section name key path and cache name if appropriate.
// nil for section name key path means "no sections".
NSFetchedResultsController *aFetchedResultsController =
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:_globalMOC
sectionNameKeyPath:nil
cacheName:nil];
self.fetchedResultsController = aFetchedResultsController;
self.fetchedResultsController.delegate = self;
NSError *error = nil;
if (![self.fetchedResultsController performFetch:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate.
// You should not use this function in a shipping application, although it may be useful
// during development. If it is not possible to recover from the error, display an alert
// panel that instructs the user to quit the application by pressing the Home button.
//
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
return _fetchedResultsController;
}
前に言ったように、コメントを外した場合にのみ結果が表示されますNSPredicate。、、、を二重引用符と一重引用符で囲んでLIKEみ==ました...=%@
Feedところで、オブジェクトを直接比較するのが最善です...
Apple によると、構文は問題ではないかもしれません。
はPost、同じ PersistentStoreCoordinator を共有する別の ManagedObjectController で作成されます。newを子 MOC の対応するオブジェクトに関連付けるために、 requiredFeedの objectID を取得します (そうしないと、異なる MOC からのオブジェクトの関連付けに関するエラーが発生します)。PostFeed
また、子 MOC が変更を通知するたびに、MOC をメイン スレッドに適切にマージします。
基本的に:私が (commented-NSPredicate) を持ってNSLogいる場合、表示された(= ) に適合する関連する RSS URLをすべて表示します。PostPostFeedFeeddetailItem
誰でも私を助けることができますか?