【发布时间】:2015-04-11 23:50:56
【问题描述】:
我正在检查是否选择了一个元素。
func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent)
{
// First, see if the game is in a paused state
if !gamePaused
{
// Declare the touched symbol and its location on the screen
let touch = touches.anyObject! as? UITouch
let location = touch.locationInNode(symbolsLayer)
这之前在 Xcode 6.2 中编译得很好,但随着 6.3 的更新,“let touch = touches.anyObject! as? UITouch”这行会抛出错误:
“Set”没有名为“anyObject”的成员
我已经阅读了许多类似的问题,但我似乎无法理解“要使用该值,您需要先“解开”它。尤其是因为答案似乎集中在通知上。
非常感谢。 W
【问题讨论】:
-
谢谢 Martin R。我已经尝试过了,但似乎不是问题所在,改为您建议的“覆盖 func touchesBegan(touches: Set
, withEvent event: UIEvent) { if let touch = touches.first as? UITouch {" 返回错误 'Set 没有名为 'first" 的成员。这就是为什么它似乎与分类为数组有关? -
奇怪,代码在我的 Xcode 6.3 项目中编译。
-
我太初学者了,无法理解为什么会这样。我所做的任何编码都充满了错误。非常感谢您的尝试。
标签: ios xcode swift set nsobject