Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS-核心数据:标准差_Ios_Core Data_Standard Deviation - Fatal编程技术网

iOS-核心数据:标准差

iOS-核心数据:标准差,ios,core-data,standard-deviation,Ios,Core Data,Standard Deviation,我使用了NSExpression方法expressionForFunction:arguments:with success for average、sum、min、max、count,代码与下面的代码相同(在苹果的文档中给出) 但当涉及到标准差(标准差:)或中位数(中位数:)。编译时我没有错误,但我只是在executeFetchRequest行上得到“SIGABRT”信号 在我的代码中,我无法找出平均值、总和、最小值、最大值、计数和标准差或中位数之间的差异。NSExpression类在这些参数

我使用了NSExpression方法expressionForFunction:arguments:with success for average、sum、min、max、count,代码与下面的代码相同(在苹果的文档中给出)

但当涉及到标准差(标准差:)或中位数(中位数:)。编译时我没有错误,但我只是在executeFetchRequest行上得到“SIGABRT”信号

在我的代码中,我无法找出平均值、总和、最小值、最大值、计数和标准差或中位数之间的差异。NSExpression类在这些参数和返回对象之间没有区别,唯一的区别是可用性(Mac OS 10.4适用于那些工作的,10.5适用于其他的)

我使用的是Xcode 4.2,我的应用程序针对的是带有ARC的iOS 5

NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"myEntity" inManagedObjectContext:app.managedObjectContext];
[request setEntity:entity];
[request setPredicate:[NSPredicate predicateWithFormat:@"something == %d",2]];

// Specify that the request should return dictionaries.
[request setResultType:NSDictionaryResultType];

// Create an expression for the key path.
NSExpression *keyPathExpression = [NSExpression expressionForKeyPath:@"anAttribute"];

// Create an expression to represent the minimum value at the key path
NSExpression *statExpression = [NSExpression expressionForFunction:@"stddev:" arguments:[NSArray arrayWithObject:keyPathExpression]];

// Create an expression description using the statExpression and returning a float.
NSExpressionDescription *expressionDescription = [[NSExpressionDescription alloc] init];

// The name is the key that will be used in the dictionary for the return value.
[expressionDescription setName:@"statData"];
[expressionDescription setExpression:statExpression];
[expressionDescription setExpressionResultType:NSFloatAttributeType];

// Set the request's properties to fetch just the property represented by the expressions.
[request setPropertiesToFetch:[NSArray arrayWithObject:expressionDescription]];

// Execute the fetch.
NSError *error = nil;
NSArray *objects = [app.managedObjectContext executeFetchRequest:request error:&error];
if (objects == nil) {
    // Handle the error.
}
float result = [[[objects objectAtIndex:0] valueForKey:@"statData"] floatValue];

感谢您的帮助。

根据可用性表,如果您的目标是iOS,那么您测试的所有功能都不应该起作用。该表显示iOS和Mac OS之间根本没有重叠——非常奇怪。听起来该表是错误的,并且最小-最大值等实际上可用于iOS,但不适用于STDEV,因此您必须执行该表自己分析。也许你是对的。即使在.h中也没有关于它的信息,没有评论,args表也在那里,在评论中,但也没有最低版本。