我有这个模型:
@interface Data : NSObject @property (nonatomic, assign) NSDate *Start; @property (nonatomic, assign) NSDate *End; @property (nonatomic, assign) int Days; @property (nonatomic, assign) double moneyEuro; @property (nonatomic, assign) double moneyUsa; @end
一个可变数组:
@property (strong, nonatomic) NSMutableArray* myArray;
将数据添加到数组中:
Data *data =[ [Data alloc] init];
data.Start = startTemp;
data.End = endTemp;
data.Days = daysTemp;
data.moneyEuro = moneyEuroTemp;
data.moneyUsa = moneyUsaTemp;
[self.myArray addObject:data];
然后我只想提取 int Days 并将它们相加:
Data * daysArr = [self.myArray valueForKeyPath:@"@sum.Days"];
NSLog(@"days %@", daysArr);
但是 daysArr 是一个 NSString ??? NSLogs 工作正常...
如何将 daysArr 更改为 int(应该是因为 Days are int)?
我试过:
Days = [daysArr intValue];
但我收到错误:没有可见的数据接口声明选择器 intValue