6523
初めまして！  
Swift 1.2 でtouchesMovedなどのtouchesの定義が変わっていて`Set<NSObject>`になっています。  
このため、

```

    override func touchesMoved(touches: NSSet, withEvent event: UIEvent) {
    let touch :UITouch = touches.anyObject() as UITouch
    var touchPoint:CGPoint = touch.locationInView(self)
    
```

以前まではこう書けていたものが、

![swift1.2の場合](https://i.stack.imgur.com/x0Ksm.png)

画像のようなエラーになってしまい、touchに何を代入すればいいのか判りません。  
よろしくお願いします。
CC BY-SA 3.0
2015-02-15T07:41:56.413
6516
2015-02-15T10:11:20.637
8290
question
swift
Swift 1.2 でtouchesMovedなどのtouchesの定義が変わっていてSet<NSObject>になっています。
こんな感じでいかがでしょうか？

```

    if let touch = touches.first as? UITouch
    
```

参照元から抜粋

> **Error** : Set doesn't have the method anyObject()
>
> if let touch = touches.anyObject() as UITouch? {
>
> Now that you have a Swift Set that has typed objects you need to update your
> cast if you use one with the touches parameter.
>
> **Fix** : Use one of the new methods of Set like first or last, which return
> optional NSObject values
>
> There's a couple gotchas with this conversion. anyObject() was a method, but
> first is a property. Firstly, you'll call them differently (i.e: no
> parenthesis).
>
> Secondly You can't use as? UITouch and as UITouch? interchangeably anymore
> with Swift 1.2 (not sure if this is a bug or intended feature).
>
> if let touch = touches.first as? UITouch {

参照元  
<http://iphonedev.tv/blog/2015/2/9/swift-12-fixes-and-breaks-a-few-things-you-
should-be-excited>
CC BY-SA 3.0
2015-02-15T10:11:20.637
6523
2015-02-15T10:11:20.637
2020-06-17T08:14:45.997
-1
3516
6516
answer