【发布时间】:2011-06-01 01:41:36
【问题描述】:
我有一个很普通的 RSS 阅读器类型的应用程序。 Core Data 中的对象有一个 pubDate 属性,它是发布的确切日期+时间。将其用于部分可为每篇文章提供自己的部分。
因此我添加了一个瞬态属性:
@dynamic sectionDay;
-(NSString *) sectionDay {
// Get the date, and convert it to the day (counld probably be done a bit more scientific!)
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
//Set the required date format
[formatter setDateStyle:NSDateFormatterLongStyle];
// Set the values;
NSString *dateString = [formatter stringFromDate:self.pubDate];
return dateString;
}
然后在 FetchedResultsController 我添加 sectionDay 作为 sectionNameKeyPath
// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"pubDay" ascending:NO] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:[self managedObjectContext] sectionNameKeyPath:@"sectionDay" cacheName:nil];
问题是我在 NSFetchedResultsController PerformFetch 上得到一个“ojbc_exception_throw”:
*
#0 0x012165a8 in objc_exception_throw
#1 0x00eba676 in -[NSSQLGenerator newSQLStatementForFetchRequest:ignoreInheritance:countOnly:nestingLevel:]
#2 0x00df2a78 in -[NSSQLAdapter _newSelectStatementWithFetchRequest:ignoreInheritance:]
#3 0x00df2881 in -[NSSQLAdapter newSelectStatementWithFetchRequest:]
#4 0x00df272e in -[NSSQLCore newRowsForFetchPlan:]
#5 0x00df1ab5 in -[NSSQLCore objectsForFetchRequest:inContext:]
#6 0x00df166e in -[NSSQLCore executeRequest:withContext:error:]
#7 0x00ea10ec in -[NSPersistentStoreCoordinator executeRequest:withContext:error:]
#8 0x00dee807 in -[NSManagedObjectContext executeFetchRequest:error:]
#9 0x00ed2c10 in -[NSFetchedResultsController performFetch:]
#10 0x0000456e in -[ArticleController getArticles] at ArticleController.m:92
*
任何建议我做错了什么?
【问题讨论】:
-
请发布异常信息
标签: iphone uitableview core-data