Ios 无法对下载到数组中的值求和

Ios 无法对下载到数组中的值求和,ios,objective-c,arrays,unrecognized-selector,Ios,Objective C,Arrays,Unrecognized Selector,我正在做一个项目,在这个项目中,我将一些值(以浮点形式存储在数据库中)下载到数组中并求和。我可以记录这些数字,但不幸的是,我最难对数组中的这些值求和 添加一些代码 详细信息。H #import <Foundation/Foundation.h> @interface Details: NSObject @property (nonatomic, strong)NSNumber *min; //@property (nonatomic, strong) NSString *min;

我正在做一个项目,在这个项目中,我将一些值(以浮点形式存储在数据库中)下载到数组中并求和。我可以记录这些数字,但不幸的是,我最难对数组中的这些值求和

添加一些代码

详细信息。H

#import <Foundation/Foundation.h>
@interface Details: NSObject
@property (nonatomic,  strong)NSNumber  *min;
//@property (nonatomic, strong) NSString *min;
@end
#导入
@接口详细信息:NSObject
@属性(非原子,强)NSNumber*min;
//@属性(非原子,强)NSString*min;
@结束
只是我将值放入数组的代码部分

for (int i = 0; i < jsonArray.count; i++)
{
    NSDictionary *jsonElement = jsonArray[i];


    tempDetails *downloadTemps = [[tempDetails alloc] init];
    downloadTemps.min = jsonElement[@"min"];
    // Add this question to the locations array
    [_locations addObject:downloadTemps];
}
for(int i=0;i
查看控制器代码

for (Details *sav in _importArray )
{

    NSLog(@"High :- %@ ", sav.min); //THIS LIST ALL MY VALUES CORRECTLY
}

NSMutableArray *newArray = [_importArray mutableCopy];

int totalSum = 0;


for(int i=0; i<[newArray count];i++)
{
    totalSum = totalSum + [[newArray objectAtIndex:i] intValue];
}

NSLog(@"Total:%d",totalSum); 
for(详细信息*sav in\u importArray)
{
NSLog(@“High:-%@”,sav.min);//此列表正确列出了我的所有值
}
NSMutableArray*newArray=[\u importArray mutableCopy];
整数总和=0;

对于(inti=0;i您要求的是选择器
intValue
,但您应该要求的是选择器
min

totalSum = totalSum + [[[newArray objectAtIndex:i] min] intValue];
在你发布的第一个街区,你已经非常接近了:

for (Details *sav in _importArray )
{
  NSLog(@"High :- %@ ", sav.min); //THIS LIST ALL MY VALUES CORRECTLY
}
然后:

顺便提一句,为什么您要求您最初编写的是浮点值的
intValue

int totalSum = 0;
for (Details *sav in _importArray )
{
  totalSum += [sav.min intValue];
}