在 Core Data 中使用特定 NSDate 进行搜索时出现问题

发布于 2024-11-27 22:12:05 字数 1070 浏览 1 评论 0原文

我正在使用以下代码在核心数据中搜索特定日期条目:

            //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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绿光 2024-12-04 22:12:05

如何设置tempDate?您确定它是 NSDate 而不是 NSArray 吗?

您收到的错误表明您正在尝试在不响应该选择器的类(在本例中为 __NSArrayI)上调用选择器 timeIntervalSinceReferenceDate

How do you set tempDate? Are you sure it's an NSDate and not an NSArray?

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文