2014-07-03 39 views
2

我SourceKitService结束,当我实现这个方法:的Xcode 6精灵套件 - SourceKitService终止

override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) 

如果删除,它的工作原理。 但是当时我的代码中出现错误。 全码:

override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) { 

    for touch: AnyObject in touches { 

     let location = touch.locationInNode(self) 

     if nodeAtPoint(location).name == "plane" { 
      println("plane touched") 
     } 
    } 
} 
+3

这个问题似乎是题外话题,因为它是关于测试版软件的错误。 – Kreiri

+1

所以我们不能在xcode 6中实现func touchesBegan? – user3722523

+0

@ user3722523你可以,但是只有在bug修复之前没有语法突出显示 –

回答

0

运行于BETA4,我能申报方法没有问题。 for touch: AnyObject in touches {看起来是个问题,因为当我将AnyObject替换为UITouch(对于您想获得的更具体)时,我得到编译器错误:NSSet! cannot be implicitly downcast to UITouch,这意味着语法会尝试将该数组转换为该类型。这似乎铸造该项目是不可能的。请参阅Annotation error in Swift for loop with array and UIView。这里是没有编译器错误同一机构代码:

for item in touches { 

    let location = (item as UITouch).locationInNode(self)  

    if self.nodeAtPoint(location).name == "plane" { 
     println("plane touched") 
    } 

} 

的错误并不足以触发SourceKit坠毁我。也许你在代码中有其他问题的地方?

0

这个错误也发生在我身上。我现在解决了它,首先将NSSet转换为NSArray,然后使用for..in循环。这没有崩溃:

override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) { 

     super.touchesBegan(touches, withEvent: event) 

     let touchArray: NSArray = touches.allObjects 

     for element in touchArray { 
      println("\(element)") 
     } 

    }