开发者

problem with searching using specific NSDate in Core Data

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];
开发者_如何学Python

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 ?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜