我在 myMutableArray 中添加了一些数据:
- (void)calculate {
DataObject* pObj = [DataObject objStart:(dataStart)
objEnd:(dataEnd)
objDay:(day)];
[self.myMutableArray addObject:pObj];
}
我只需要提取 day (int) 并对所有值求和。我在想这样的事情,但我想念如何只提取一天......
for(id *tObj in self.myMutableArray) {
// day = day + day
}
DataObject 在这里实现:
@implementation DataObject
+ (id)objStart:(NSDate*)objStart objEnd:(NSDate*)objEnd objDay:(int)objDay {
DataObject *dataObject = [[self alloc] init];
dataObject.objStart = objStart;
dataObject.objEnd = objEnd;
dataObject.objDay = objDay;
return dataObject;
}
@end