質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

解決済

1回答

391閲覧

viewController間でボタンを押したら次の画面に値を渡す。

hahum

総合スコア65

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2018/12/21 08:21

ストップボタンを押したらstartViewControllerのcountの値を次の画面のcountLabel2に表示させたいため以下のコードを書きましたがThread 1: signal SIGABRTのエラーが出てしまいます。解決方法を教えていただきたいです。

startViewController

swift

1@IBAction func stop(_ sender: Any) { 2 3 4 //タイマーストップ 5 self.timer1.invalidate() 6 self.timer2.invalidate() 7 self.timer3.invalidate() 8 self.timer4.invalidate() 9 self.timer5.invalidate() 10 self.timer6.invalidate() 11 self.timer7.invalidate() 12 self.timer8.invalidate() 13 self.timer9.invalidate() 14 self.timer10.invalidate() 15 self.timer11.invalidate() 16 self.timer12.invalidate() 17 self.timer13.invalidate() 18 self.timer14.invalidate() 19 self.timer15.invalidate() 20 self.timer16.invalidate() 21 self.timer17.invalidate() 22 self.timer18.invalidate() 23 self.timer19.invalidate() 24 self.timer20.invalidate() 25 self.timer21.invalidate() 26 self.timer22.invalidate() 27 self.timer23.invalidate() 28 29 30 //音声を停止 31 audioPlayer.stop() 32 33 //countLabel&timeLabelの値を渡す 34 performSegue(withIdentifier: "toResultViewController", sender: nil) 35 36 } 37 38 //countLabel&timeLabelの値をResultViewControllerに遷移の関数 39 override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 40 if (segue.identifier == "toResultViewController") { 41 let ResultViewController: ResultViewController = 42 segue.destination as! ResultViewController 43 44 ResultViewController.labelText = self.count 45 } 46 } 47

resultVIewController

swift

1import UIKit 2 3class ResultViewController: UIViewController { 4 5 //variable 6 var labelText = 0 7 8 9 //Outlet 10 @IBOutlet var countLabel2: UILabel! 11 12 @IBOutlet var timerLabel2: UILabel! 13 14 override func viewDidLoad() { 15 super.viewDidLoad() 16 17 countLabel2.text = String(labelText) 18 } 19 20

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

fuzzball

2018/12/21 08:25

Consoleに表示されるエラーメッセージを書いて下さい。
hahum

2018/12/21 08:38

これで合ってますか?デバッカに表示された文字です 2018-12-21 17:19:32.671878+0900 ShuttleRunApp[74124:4981036] libMobileGestalt MobileGestalt.c:890: MGIsDeviceOneOfType is not supported on this platform. 2018-12-21 17:19:44.022709+0900 ShuttleRunApp[74124:4981036] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ShuttleRunApp.ResultViewController 0x7fc4fbf1d480> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key countLabel.' *** First throw call stack: ( 0 CoreFoundation 0x000000010baf41bb __exceptionPreprocess + 331 1 libobjc.A.dylib 0x000000010b09a735 objc_exception_throw + 48 2 CoreFoundation 0x000000010baf3d29 -[NSException raise] + 9 3 Foundation 0x000000010aac5de4 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292 4 UIKitCore 0x0000000115ead292 -[UIViewController setValue:forKey:] + 87 5 UIKitCore 0x0000000116144573 -[UIRuntimeOutletConnection connect] + 109 6 CoreFoundation 0x000000010badfcfd -[NSArray makeObjectsPerformSelector:] + 317 7 UIKitCore 0x00000001161412b9 -[UINib instantiateWithOwner:options:] + 1814 8 UIKitCore 0x0000000115eb4452 -[UIViewController _loadViewFromNibNamed:bundle:] + 383 9 UIKitCore 0x0000000115eb4ddc -[UIViewController loadView] + 177 10 UIKitCore 0x0000000115eb50ee -[UIViewController loadViewIfRequired] + 175 11 UIKitCore 0x0000000115eb5940 -[UIViewController view] + 27 12 UIKitCore 0x0000000115dd84ee -[_UIFullscreenPresentationController _setPresentedViewController:] + 89 13 UIKitCore 0x0000000115dcbedf -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133 14 UIKitCore 0x0000000115ec89ad -[UIViewController _presentViewController:withAnimationController:completion:] + 3713 15 UIKitCore 0x0000000115ecb74b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99 16 UIKitCore 0x0000000115ecbdd9 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511 17 UIKitCore 0x0000000115ecb6b1 -[UIViewController _presentViewController:animated:completion:] + 173 18 UIKitCore 0x0000000115ecb9f0 -[UIViewController presentViewController:animated:completion:] + 150 19 UIKitCore 0x00000001166719c0 __74-[UIStoryboardPresentationSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 133 20 UIKitCore 0x00000001166767fb -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 276 21 UIKitCore 0x00000001166766b9 -[UIStoryboardSegueTemplate _perform:] + 82 22 UIKitCore 0x0000000115eb84bc -[UIViewController performSegueWithIdentifier:sender:] + 99 23 ShuttleRunApp 0x000000010a0bbac2 $S13ShuttleRunApp19StartViewControllerC4stopyyypF + 1970 24 ShuttleRunApp 0x000000010a0bbb9c $S13ShuttleRunApp19StartViewControllerC4stopyyypFTo + 76 25 UIKitCore 0x00000001164d5ecb -[UIApplication sendAction:to:from:forEvent:] + 83 26 UIKitCore 0x0000000115f110bd -[UIControl sendAction:to:forEvent:] + 67 27 UIKitCore 0x0000000115f113da -[UIControl _sendActionsForEvents:withEvent:] + 450 28 UIKitCore 0x0000000115f1031e -[UIControl touchesEnded:withEvent:] + 583 29 UIKitCore 0x00000001165110a4 -[UIWindow _sendTouchesForEvent:] + 2729 30 UIKitCore 0x00000001165127a0 -[UIWindow sendEvent:] + 4080 31 UIKitCore 0x00000001164f0394 -[UIApplication sendEvent:] + 352 32 UIKitCore 0x00000001165c55a9 __dispatchPreprocessedEventFromEventQueue + 3054 33 UIKitCore 0x00000001165c81cb __handleEventQueueInternal + 5948 34 CoreFoundation 0x000000010ba59721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 35 CoreFoundation 0x000000010ba58f93 __CFRunLoopDoSources0 + 243 36 CoreFoundation 0x000000010ba5363f __CFRunLoopRun + 1263 37 CoreFoundation 0x000000010ba52e11 CFRunLoopRunSpecific + 625 38 GraphicsServices 0x000000010fda91dd GSEventRunModal + 62 39 UIKitCore 0x00000001164d481d UIApplicationMain + 140 40 ShuttleRunApp 0x000000010a0b26b7 main + 71 41 libdyld.dylib 0x0000000110c2e575 start + 1 42 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
fuzzball

2018/12/21 08:54

ここに書かずに質問内に追記して下さい。
guest

回答1

0

ベストアンサー

reason: '[<ShuttleRunApp.ResultViewController 0x7fc4fbf1d480> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key countLabel.

countLabelが定義されていないというエラーです。
xib/StoryboardにcountLabelのアウトレットの残骸があるのではないでしょうか?

投稿2018/12/21 08:51

fuzzball

総合スコア16731

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問