2

エラーが発生しています (iOS): キャッチされていない例外 'NSInvalidArgumentException' が原因でアプリを終了しています。 )'

以下のコードで、何か不足していますか? max: 集計関数を使用していますが、このエラーは誰に表示されますか? "logtijd" - コア データの日付 (NSDate)。

max: 関数は iOS で利用できますか? このリンクを参照してください: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSExpression_Class/Reference/NSExpression.html#//apple_ref/occ/clm/NSExpression/expressionForFunction:arguments :

集計関数 @"average" が機能します。

   NSFetchRequest *request = [[NSFetchRequest alloc] init];

    [request setEntity:[NSEntityDescription entityForName:@"Tijden" inManagedObjectContext:self.context]];

NSExpression *keyPathExpression = [NSExpression expressionForKeyPath:@"logtijd"];    
NSExpression *maxExpression = [NSExpression expressionForFunction:@"max:" arguments:[NSArray arrayWithObject:keyPathExpression]];

NSExpressionDescription *expressionDescription = [[NSExpressionDescription alloc] init];

[expressionDescription setName:@"maxlogtijd"];
[expressionDescription setExpression:maxExpression];
[expressionDescription setExpressionResultType:NSDateAttributeType];

    [request setResultType:NSDictionaryResultType];
[request setPropertiesToFetch:[NSArray arrayWithObjects:@"starttijd", expressionDescription, nil]];
    [request setPropertiesToGroupBy:[NSArray arrayWithObject:@"starttijd"]];
    [request setPredicate:[NSPredicate predicateWithFormat:@"atleet == %@ AND workout == %@", self.atleetGeselecteerd, self.workoutGeselecteerd]];

    return [self.context executeFetchRequest:request error:nil];
4

0 に答える 0