Considering a Swift Object class Sheep having a simple property var position: CGRect
class Sheep {
var position: CGRect
init() {
position = CGRectZero
}
}
In an array of Sheep Array<Sheep> How can I get the Sheep with the highest position.origin.y?
I tried the following but got an error: could not find member y
func firstSheep(sheeps: Array<Sheep>) -> Sheep
{
return sheeps.reduce(sheeps[0]) {max($0.position.origin.y, $1.position.origin.y)}
}
All classes import
import Foundation
import QuartzCore