swift的函数可以使用元组的形式返回多个值。

class func getMaxMinWeight(arr:[YMDateRecord]) -> (max:Float,min:Float){
        var maxV:Float = 0
        var minV:Float = 0
        
        for info in arr{
            if info.weight >= maxV{
                maxV = info.temperature
            }
            if info.weight <= minV{
                minV = info.temperature
            }
        }
        
        return (maxV,minV)
    }

使用:

let result = YMDateRecordDAO.getMaxMinTemperature(arr: arr)
minVal = CGFloat(result.min)
maxVal = CGFloat(result.max)

 

相关文章:

  • 2022-03-05
  • 2021-06-13
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案