1
私は日々の食事やトレーニングセッションを表す簡単なモデルを持っています。私はCoreDataから今日を得ることに問題があります。次のエラーが表示されます。CoreDataのトラブルと日付の検索
2011-11-14 11:41:44.999 CalorificCounter[21002:fb03] -[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x6a6d1a0
2011-11-14 11:41:45.001 CalorificCounter[21002:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x6a6d1a0'
コード
-(Day *)getDayForDate:(NSDate *)date
{
Day *day;
date = [self dateAtStartOfDay:date];
NSFetchRequest *request = [[NSFetchRequest alloc]init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Day"
inManagedObjectContext:[self managedObjectContext]];
//Find the object that matches the given date from a predicate
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date == \"%@\"",date];
[request setEntity:entity];
[request setPredicate:predicate];
//Try to fetch
NSError *error;
NSArray *result = [[self managedObjectContext] executeFetchRequest:request
error:&error ] ;
エラーがフェッチ要求の実行時に発生します。私は実行を追跡し、すべてが正しいタイプであるようです(少なくとも私は文字列を渡すことはありません)。前もって感謝します。
UPDATEいけないは、日付オブジェクトに文字列を代入していたときにこの問題が発生する引用符で
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"date == %@",date];
データストアに何か問題がある可能性があります。何らかの理由で実際に文字列を取得している日付が必要です。あなたの店をもう一度見せてください。 – drharris
私は日付を送信していますが、文字列を取得しています。うん、ここのタイプには何か問題があります。 – botptr
この問題を解決しましたか? – newenglander