使用環境 : Xcode6.1(6A1052d) / OS X Yosemite 10.10
※ 注意 筆者はSwiftを勉強し始めてから1時間しか経っていないので詳しいことは分かりません
とりあえず動くようにするための方法を記録として残しておきます。
Swiftを勉強しようとしてSwiftクローン版のFlappyBirdを落とした
→ これ(https://github.com/fullstackio/FlappySwift)
コンパイルした
エラーの詳細とその対処
'dataWithContentsOfFile(_:options:error:)' is unavailable: use object construction 'NSData(contentsOfFile:options:error:)'
dataWithContentsOfFileのerrorオプションはコンストラクタで使えないとか言ってる?
Swiftの仕様変更だと思うのですが、当方1時間しか勉強していないので誰か教えて下さい。
このエラーは以下の行で出力されるので、
let sceneData = NSData.dataWithContentsOfFile(path!, options: .DataReadingMappedIfSafe, error: nil)
こう直す。
var sceneData = NSData(contentsOfFile: path!, options: .DataReadingMappedIfSafe, error: nil)!
下の方には同じエラーが2箇所出ています。
Method 'fromRaw' has been replaced with a property 'rawValue'
これは以下の行で出ているので、
return Int(UIInterfaceOrientationMask.AllButUpsideDown.toRaw())
toRaw()をrawValueに置き換えてやる
return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
こちらについてはQiitaで解説を見つけられました。
Xcode6.1 Beta2での変更らしいです。
http://qiita.com/dankogai/items/fe86f43a0158c13082ad
参考にしたサイト
THE LAST DAY (http://ngw.jp/~tato/wp/?tag=swift)