在 Core Data 中使用特定 NSDate 进行搜索时出现问题
我正在使用以下代码在核心数据中搜索特定日期条目:
//NSDate *tempDate=<a date element fetched from a core data query>
NSManagedObjectContext *context=[self managedObjectContext];
RecentMovieInfo *recent3 = nil;
request = [[NSFetchRequest alloc] init];
entity=[NSEntityDescription entityForName:@"RecentMovies" inManagedObjectContext:context2];
[request setEntity:entity];
[request setPredicate:[NSPredicate predicateWithFormat:@"DateTime=%@",tempDate]];
recent3 = [[context2 executeFetchRequest:request error:&error] lastObject];
但是,我收到以下错误:
2011-08-03 15:28:59.573 EncameoApp[2447:707] -[__NSArrayI timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x2c4640
2011-08-03 15:28:59.641 EncameoApp[2447:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x2c4640'
有帮助吗?
I am using the following code to search for a specific date entry in Core Data :
//NSDate *tempDate=<a date element fetched from a core data query>
NSManagedObjectContext *context=[self managedObjectContext];
RecentMovieInfo *recent3 = nil;
request = [[NSFetchRequest alloc] init];
entity=[NSEntityDescription entityForName:@"RecentMovies" inManagedObjectContext:context2];
[request setEntity:entity];
[request setPredicate:[NSPredicate predicateWithFormat:@"DateTime=%@",tempDate]];
recent3 = [[context2 executeFetchRequest:request error:&error] lastObject];
However, I am getting the following error:
2011-08-03 15:28:59.573 EncameoApp[2447:707] -[__NSArrayI timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x2c4640
2011-08-03 15:28:59.641 EncameoApp[2447:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x2c4640'
Any help ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如何设置
tempDate
?您确定它是NSDate
而不是NSArray
吗?您收到的错误表明您正在尝试在不响应该选择器的类(在本例中为
__NSArrayI
)上调用选择器timeIntervalSinceReferenceDate
。How do you set
tempDate
? Are you sure it's anNSDate
and not anNSArray
?The error you're getting says that you're trying to call the selector
timeIntervalSinceReferenceDate
on a class (in this case an__NSArrayI
) that doesn't respond to that selector.