ios - How get the total sum of float from a NSMutableArray

后端 未结 3 914
孤城傲影
孤城傲影 2021-01-27 21:48

I created a NSMutableArray which contains a lot of NSString and float

DataOrder *addClient = [[DataOrder alloc ] initWithName:[[DataOrder instance]product] pric         


        
3条回答
  •  星月不相逢
    2021-01-27 22:22

    Something like this will work:

    float total = 0;
    for (DataOrder *client in [[ArrayBuying instance] tableau]) {
        total += client.price;
    }
    
    NSLog(@"total = %f", total);
    

    I'm just guessing that your DataOrder class has a price property. Use what you really have.

提交回复
热议问题