I had this code with a completion handler working in Xcode 6 beta 4 that no longer works in Xcode 6 beta 5.
dropsToRemove.bridgeToObjectiveC().makeObjectsPerformSelector("removeFromSuperview")
Full method...
func animateRemovingDrops(dropsToRemove: [UIView]) {
println(__FUNCTION__)
UIView.animateWithDuration(1.0,
animations: {
for dropView in dropsToRemove {
let x = CGFloat(UInt(arc4random_uniform(UInt32(UInt(self.gameView.bounds.size.width) * 5)))) - self.gameView.bounds.size.width * 2
let y = self.gameView.bounds.size.height
dropView.center = CGPointMake(x, -y)
}}, completion: { finished in
dropsToRemove.bridgeToObjectiveC().makeObjectsPerformSelector("removeFromSuperview")
})
}
The error is '[UIView]' does not have a member named 'bridgeToObjectiveC'
Note that the CGFloat and Uint casting in the method is for a beta 4 workaround, I just haven't updated that part yet. That issue is covered at: ‘CGFloat’ is not convertible to ‘UInt8' and other CGFloat issues with Swift and Xcode 6 beta 4
I thought the solution for dealing with the completion handler might be to treat the array as an NSArray as detailed in: What is the swift equivalent of makeObjectsPerformSelector?
(dropsToRemove as NSArray).makeObjectsPerformSelector("removeFromSuperview")
However, assuming I got the syntax right, simply results in another error 'makeObjectsPerformSelector' is unavailable: 'performSelector' methods are unavailable
Is this a new Swift bug, or something I'm missing in the release notes?
See Question&Answers more detail:os