前提・実現したいこと
Xcode上のSwiftでiOSのアプリを作っています。
ボタンが押されると音がなるアプリを完成させたいです。
発生している問題・エラーメッセージ
App Storeに提出したところ、
以下のよう却下を頂きました。
要約すると、iOS 13.1.1のiPadにて、ボタンが押されたらcrashしたとのことです。
また、私が所持しているiPhone XR(iOS12.4.1)では正常に動作確認しました。
ただ、iPhone XS(13.1.1)では、ボタンを押した際にアプリが強制終了しました。
以下、appleからのエラーメッセージ
【Guideline 2.1 - Performance - App Completeness】
Your app crashed on iPad running iOS 13.1.1 on WiFi when we:
- Tap on the cat at the time of review.
We have attached detailed crash logs to help troubleshoot this issue.
Next Steps
To resolve this issue, please revise your app and test it on a device to ensure that it runs as expected.
Resources
For information on how to symbolicate and read a crash log, please review Tech Note TN2151 Understanding and Analyzing Application Crash Reports.
該当のソースコード
Swift
1 2import UIKit 3import AVFoundation 4 5class ViewController: UIViewController { 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 // Do any additional setup after loading the view. 10 } 11 12 // ねこの音源ファイルを指定 13 let nekoPath01 = 14 Bundle.main.bundleURL.appendingPathComponent("02_cats_01.mp3") 15 let nekoPath02 = 16 Bundle.main.bundleURL.appendingPathComponent("02_cats_02.mp3") 17 let nekoPath03 = 18 Bundle.main.bundleURL.appendingPathComponent("02_cats_03.mp3") 19 let nekoPath04 = 20 Bundle.main.bundleURL.appendingPathComponent("02_cats_04.mp3") 21 let nekoPath05 = 22 Bundle.main.bundleURL.appendingPathComponent("02_cats_05.mp3") 23 let nekoPath06 = 24 Bundle.main.bundleURL.appendingPathComponent("02_cats_06.mp3") 25 26 27 28 // ねこのプライヤーインスタンスを作成 29 var nekoPlayer = AVAudioPlayer() 30 var catsNumber = 0 31 32 @IBAction func neko(_ sender: Any) { 33 do { 34 var newCatsNumber = 0 35 36 // ランダムに結果を出すが、前回の結果と異なる場合のみ採用 37 // repeatは繰り返しを意味する 38 39 repeat { 40 // 0,1,2,3,4,5の数値をランダムに算出 41 // arc4random_uniform()の戻り値はUInt32だが、Swiftの標準的な整数型Intにキャスト(変換)する 42 newCatsNumber = Int(arc4random_uniform(6)) 43 44 // 前回と同じ結果の時は再度ランダムに数値を出す 45 // 異なる結果の時は、repeatを抜ける 46 } while catsNumber == newCatsNumber 47 48 // 新しい猫声の結果を格納 49 catsNumber = newCatsNumber 50 51 if catsNumber == 0 { 52 nekoPlayer = try AVAudioPlayer(contentsOf: nekoPath01, fileTypeHint: nil) 53 } else if catsNumber == 1 { 54 nekoPlayer = try AVAudioPlayer(contentsOf: nekoPath02, fileTypeHint: nil) 55 } else if catsNumber == 2 { 56 nekoPlayer = try AVAudioPlayer(contentsOf: nekoPath03, fileTypeHint: nil) 57 } else if catsNumber == 3 { 58 nekoPlayer = try AVAudioPlayer(contentsOf: nekoPath04, fileTypeHint: nil) 59 } else if catsNumber == 4 { 60 nekoPlayer = try AVAudioPlayer(contentsOf: nekoPath05, fileTypeHint: nil) 61 } else if catsNumber == 5 { 62 nekoPlayer = try AVAudioPlayer(contentsOf: nekoPath06, fileTypeHint: nil) 63 } 64 // ねこの音源再生 65 nekoPlayer.play() 66 } catch { 67 print("ねこでエラーが発生しました!") 68 } 69 } 70 71 72} 73
試したこと
ランダム関数がダメなのかなと思い、ランダム関数の書き方を変えてみましたが
問題は解決しませんでした。
どうぞよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー