Xcodeでアプリを作っていて、たくさんアラートを表示するので、アラート部分のみを外部のSwiftファイル化してViewControllerから呼びたいと考えています。
以下のように外部ファイルを作成したところ、エラーが出てしまいます。
検索しても解決することができず、困っております。
どなたか解決法をご存知の方がいらっしゃればご教示いただけますと大変助かります。
よろしくお願いいたします。
外部Swiftファイル
Swift
1import Foundation 2 3class Alert: UIAlertController { 4 class func show(alertNum : Int) { 5 var alert = UIAlertController(title: "", message: "", preferredStyle: .Alert) 6 switch alertNum{ 7 //チュートリアル 8 case 1: 9 alert = UIAlertController(title: "タイトル", message: "エラー出ませんように", preferredStyle: .Alert) 10 let actionCancel = UIAlertAction(title: "キャンセル", style: .Cancel) { 11 action in print("Pushed CANCEL!") 12 } 13 alert.addAction(actionCancel) 14 break 15 default: 16 break 17 } 18 presentViewController(alert, animated: true, completion: nil) //ここでエラーが出ます。"Extra argument 'animated' in call" 19 } 20}
エラー文
Extra argument 'animated' in call
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/04/24 02:26