是否可以返回某个人的所有值并获得他们的最高分
let barScore: String = "9.246"
let numbers = [1, 6, 3, 9.245, 4, 6]
//numbers.minElement()
let value = numbers.maxElement()
if (Float(value!) < Float(barScore)) {
print("True")
} else {
print("False")
}
这样做很好,但似乎无法从核心数据中获得相同的效果。
let request = NSFetchRequest(entityName: "MeetResult")
request.predicate = NSPredicate(format: "gymnast.fullName = %@", "\(gymnastNameText.text!)")
do {
let results = try AD.managedObjectContext.executeFetchRequest(request) as! [MeetResult]
let value = results.maxElement()
for result in results {
print("Gymnast Name: \(gymnastNameText.text!)")
print("Bar Score: \(result.barsScore!)")
}
} catch {
fatalError("Falied to get results")
}