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

1

11

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?

Wanitawanneeickel answered 12/4, 2015 at 21:10 Comment(1)
#28772396, #29567361, #29593911Tibiotarsus
C
33

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

touches.first
Cordeiro answered 12/4, 2015 at 21:18 Comment(1)
"Set - does not have an equivalent of NSSet anyObject method" – What about first ?Tibiotarsus

© 2022 - 2024 — McMap. All rights reserved.