Cannot use mutating member on immutable value: 'subviews' is a get-only property

for subview in self.subviews.reverse() //ERROR HERE
{
    let insideSubview = self.convertPoint(point, toView: subview)
    if let sview = subview.overlapHitTest(insideSubview, withEvent: event)
    {
        return sview
    }
}

I get the aforementioned error title there, how would I fix this?


Use reversed rather than reverse. The former returns a new, reversed array. The latter attempts to mutate the existing array, which you don’t want in this case.

Thus:

for subview in subviews.reversed() { ... }