ストップボタンを押したら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
Consoleに表示されるエラーメッセージを書いて下さい。
これで合ってますか?デバッカに表示された文字です
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)
ここに書かずに質問内に追記して下さい。
回答1件
あなたの回答
tips
プレビュー