解决方案 »

  1.   

    KVC 可以直接从NSArray 中取出最大值. 如下是Apple 官方文档@max
    The @max operator compares the values of the property specified by the key path to the right of the operator and returns the maximum value found. The maximum value is determined using the compare: method of the objects at the specified key path. The compared property objects must support comparison with each other. If the value of the right side of the key path is nil, it is ignored.The following example returns the maximum value of the date values (date of the latest transaction) for the Transaction objects in transactions:NSDate *latestDate = [transactions valueForKeyPath:@"@max.date"];