2012-04-27 49 views
1

我收到以下错误,当我打电话[self.fetchedResultsController performFetch。错误[NSFetchedResultsController performFetch]

*终止应用程序由于未捕获的异常 'NSInvalidArgumentException',原因是:“* - [的NSFileManager fileSystemRepresentationWithPath:]:转换失败/用户/ ivanevf /库/应用程序支持/ iPhone模拟器/ 5.1 /应用/ 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; 
} 

任何想法这里发生了什么? 谢谢!

p.s.我尝试了几个随机的东西: 1.从模拟器中删除应用程序目录。 (/用户/ ivanevf /库/应用程序支持/ iPhone模拟器/ 5.1 /应用/ 0EF75071-5C99-4181-8D4D-4437351EC1F4) 2.注释掉setPredicate,setSortDescriptors线方法调用

回答

1

看起来你有一个额外的转义字符cacheName。尝试:

NSString *cacheName = [NSString stringWithFormat:@"%dConversation%d", 
               self.viewType, 
               self.location.bid]; 
+1

你是一个绅士和学者。我现在会在一个耻辱的角落里哭泣。 – Ivan 2012-04-27 20:14:29

0

我尝试此, 的NSString * cacheName = [NSString的stringWithFormat:@ “%d%会话%d”,1,2];它抛出: 1onversation9283099

这是一个普通的字符串,没有什么奇怪的。

相关问题