統計を機能させるために助けが必要です...コアデータを使用してユーザー入力からの値を保存し、各「行」には時間値があります。
ここで、特定の時間範囲にあるこれらの値のいくつかを計算する必要があります。たとえば、過去30日間です。しかし、私はそれを行う方法がわかりません。私は日付と時間のレンジャーを扱うのは少し新しいです。
誰かが私を助けることができますか?
よろしく、インゲマール
統計を機能させるために助けが必要です...コアデータを使用してユーザー入力からの値を保存し、各「行」には時間値があります。
ここで、特定の時間範囲にあるこれらの値のいくつかを計算する必要があります。たとえば、過去30日間です。しかし、私はそれを行う方法がわかりません。私は日付と時間のレンジャーを扱うのは少し新しいです。
誰かが私を助けることができますか?
よろしく、インゲマール
ご回答有難うございます。私はあなたの方法を試してみます。
私は自分でこの解決策を見つけました、それについて何か懸念はありますか?
NSTimeInterval aktuellesDatumInSekunden = [aktuellesDatum timeIntervalSinceReferenceDate];
NSTimeInterval vordreissigTagen = [letztedreizigTage timeIntervalSinceReferenceDate];
double dBoluse = 0;
double dWerteKleinerSechzig = 0;
for (TblBolusWerte *ausgabeBoliTag in statistikDataWithPredicate){
NSTimeInterval DatumAusDB = [ausgabeBoliTag.creationTime timeIntervalSinceReferenceDate];
if (DatumAusDB >= vordreissigTagen && DatumAusDB <= aktuellesDatumInSekunden){
データをフィルタリングするには、述語を使用する必要があります。
NSManagedObjectContext *context; // Assume this exists.
NSEntityDescription *entityDescription; // Assume this exists.
NSDate minDate, maxDate; // Assume these exist.
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDescription];
NSPredicate *setPredicate:predicate = [NSPredicate predicateWithFormat:@"date BETWEEN %@",
[NSArray arrayWithObjects:minDate, maxDate, nil]];
[request setPredicate:predicate];
NSError *error;
NSArray *filteredResult = [context executeFetchRequest:request error:&error];
// Handle error.
[request release];