swift2(xcode7)にソースコードを変換したあとエラーになった。
次の2つがエラーになって、コンパイルできなくなった。
自動変換してくれればいいのに。。調べるのに1時間くらいかかったyo-
1、UITouchのエラー
1行目のoverrideのところは自動変換してくれるけど、2行目はエラーになった。で、下記のとおり書けば通った!!
override func touchesBegan(touches:Set<UITouch>, withEvent event: UIEvent!) { let touch :UITouch! = touches.first }
2、AVAudioPlayer!のエラー
自動変換後、1行目のAVAudioPlayerのあとに「!」をつけるだけで解決。
var a_audioPlayer:AVAudioPlayer! = AVAudioPlayer(); let a_sound_data = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("A", ofType: "wav")!) a_audioPlayer = try? AVAudioPlayer(contentsOfURL: a_sound_data) a_audioPlayer.play()