Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Set' <NSObject> does not have a member named 'anyObject' [duplicate]

today i updated xcode with Swift 1.2 my code was working well on Swift 1.1 but when i updated i got this error:

'Set' does not have a member named 'anyObject'

Here's my code:

override public func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
    let location:CGPoint? = touches.anyObject()?.locationInView(self)
    if let loc = location {
        if (!CGRectContainsPoint(ScaleRect(self.bounds, n: 2.0), loc)) {
            self.highlighted = false
        }
    }
}

Does you guys have an idea on how can i fix that please?

like image 416
user2540538 Avatar asked Apr 12 '15 21:04

user2540538


1 Answers

Use first which is the equivalent of anyObject of NSSet for Swift sets:

touches.first
like image 53
Wojtek Surowka Avatar answered Oct 17 '22 02:10

Wojtek Surowka