I am trying to get the total value totalPurchaseSum of an property stockPurchasePrice from all objects in an array arrPurchaseActions.
This are the properties (user.h):
@property (nonatomic, strong) NSMutableArray *arrPurchaseActions;
@property (nonatomic) CGFloat totalSumPurchased;
-(CGFloat)totalSumPurchased:(CGFloat)stockPurchasePrice;
This is the method I am trying to use (User.m):
-(CGFloat)totalSumPurchased:(CGFloat)stockPurchasePrice
{
CGFloat totalSumPurchased = 0;
size_t count = [self.arrPurchaseActions count];
for (int i = 0; i < count; i++) {
totalSumPurchased = totalSumPurchased + [[self.arrPurchaseActions[i].stockPurchasePrice];
}
return totalSumPurchased;
}
Can anybody help me to get this working?