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)