1

[self.fetchedResultsController PerformFetch]を呼び出すと、次のエラーが発生します。

*キャッチされなかった例外'NSInvalidArgumentException'が原因でアプリを終了しています、理由:'* -[NSFileManager fileSystemRepresentationWithPath:]:/ Users / ivanevf / Library / Application Support / iPhone Simulator / 5.1 / Applications/0EF75071-5C99-4181-8D4D-の変換に失敗しました4437351EC1F4 / Library / Caches / .CoreDataCaches / SectionInfoCaches / 0

これは、コントローラーを初期化した後、コントローラーに対して行う最初の呼び出しです。初期化は次のようになります。

- (NSFetchedResultsController *)fetchedResultsController
{
   if (_fetchedResultsController != nil) {
      return _fetchedResultsController;
 }

// Create and configure a fetch request with the Book entity.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Conversation" inManagedObjectContext:self.objectContext];
[fetchRequest setEntity:entity];

// Create the sort descriptors array.
NSSortDescriptor *msgAgeDescriptor = [[NSSortDescriptor alloc] initWithKey:@"message" ascending:NO comparator:^NSComparisonResult(id obj1, id obj2) {
  // some code
}];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:msgAgeDescriptor, nil];

[fetchRequest setPredicate:[self fetchPredicate]];
[fetchRequest setSortDescriptors:sortDescriptors];
NSString *cacheName = [NSString stringWithFormat:@"%d%Conversation%d", self.viewType, self.location.bid];
// Create and initialize the fetch results controller.
_fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.objectContext sectionNameKeyPath:nil cacheName:cacheName];
_fetchedResultsController.delegate = self;

return _fetchedResultsController;
}

ここで何が起こっているのか分かりますか?ありがとう!

ps私が試したいくつかのランダムなこと:1。エミュレータからアプリディレクトリを削除します。(/ Users / ivanevf / Library / Application Support / iPhone Simulator / 5.1 / Applications / 0EF75071-5C99-4181-8D4D-4437351EC1F4)2. setPredicate、setSortDescriptors行のメソッド呼び出しをコメントアウトする

4

2 に答える 2

1

に余分なエスケープ文字があるようですcacheName。試す:

NSString *cacheName = [NSString stringWithFormat:@"%dConversation%d",
                                                 self.viewType,
                                                 self.location.bid];
于 2012-04-27T20:13:38.900 に答える