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

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

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

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

Swift

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

Q&A

解決済

1回答

2540閲覧

Swiftがクラッシュ

souroppy

総合スコア44

Xcode

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

Swift

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

0グッド

0クリップ

投稿2016/06/03 13:33

一つ目の画面から二つ目の画面に移動しようとすると、エラーが出てきてクラッシュしてしまします。原因を教えてください。

2016-06-03 22:23:42.099 testt[935:38371] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<testt.ViewController 0x7ff023caf690> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key onea.' *** First throw call stack: ( 0 CoreFoundation 0x00000001085ddd85 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010a381deb objc_exception_throw + 48 2 CoreFoundation 0x00000001085dd9c9 -[NSException raise] + 9 3 Foundation 0x00000001089af19b -[NSObject(NSKeyValueCoding) setValue:forKey:] + 288 4 UIKit 0x0000000108f98d0c -[UIViewController setValue:forKey:] + 88 5 UIKit 0x00000001091cf7fb -[UIRuntimeOutletConnection connect] + 109 6 CoreFoundation 0x0000000108517890 -[NSArray makeObjectsPerformSelector:] + 224 7 UIKit 0x00000001091ce1de -[UINib instantiateWithOwner:options:] + 1864 8 UIKit 0x0000000108f9f8d6 -[UIViewController _loadViewFromNibNamed:bundle:] + 381 9 UIKit 0x0000000108fa0202 -[UIViewController loadView] + 178 10 UIKit 0x0000000108fa0560 -[UIViewController loadViewIfRequired] + 138 11 UIKit 0x0000000108fa0cd3 -[UIViewController view] + 27 12 UIKit 0x000000010976c024 -[_UIFullscreenPresentationController _setPresentedViewController:] + 87 13 UIKit 0x0000000108f705ca -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133 14 UIKit 0x0000000108fb35bb -[UIViewController _presentViewController:withAnimationController:completion:] + 4002 15 UIKit 0x0000000108fb685c -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 489 16 UIKit 0x0000000108fb636b -[UIViewController presentViewController:animated:completion:] + 179 17 UIKit 0x0000000108fbb9ea -[UIViewController _showViewController:withAction:sender:] + 280 18 UIKit 0x000000010941ac70 __66-[UIStoryboardShowSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 147 19 UIKit 0x000000010954d630 -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 460 20 UIKit 0x000000010954d433 -[UIStoryboardSegueTemplate _perform:] + 82 21 UIKit 0x000000010954d6f7 -[UIStoryboardSegueTemplate perform:] + 156 22 UIKit 0x0000000108e07a8d -[UIApplication sendAction:to:from:forEvent:] + 92 23 UIKit 0x0000000108f7ae67 -[UIControl sendAction:to:forEvent:] + 67 24 UIKit 0x0000000108f7b143 -[UIControl _sendActionsForEvents:withEvent:] + 327 25 UIKit 0x0000000108f7a263 -[UIControl touchesEnded:withEvent:] + 601 26 UIKit 0x0000000108e7a99f -[UIWindow _sendTouchesForEvent:] + 835 27 UIKit 0x0000000108e7b6d4 -[UIWindow sendEvent:] + 865 28 UIKit 0x0000000108e26dc6 -[UIApplication sendEvent:] + 263 29 UIKit 0x0000000108e00553 _UIApplicationHandleEventQueue + 6660 30 CoreFoundation 0x0000000108503301 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 31 CoreFoundation 0x00000001084f922c __CFRunLoopDoSources0 + 556 32 CoreFoundation 0x00000001084f86e3 __CFRunLoopRun + 867 33 CoreFoundation 0x00000001084f80f8 CFRunLoopRunSpecific + 488 34 GraphicsServices 0x000000010cc73ad2 GSEventRunModal + 161 35 UIKit 0x0000000108e05f09 UIApplicationMain + 171 36 testt 0x00000001083f6362 main + 114 37 libdyld.dylib 0x000000010ae4592d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
import UIKit class ViewController: UIViewController { @IBOutlet weak var start: UIButton! @IBOutlet weak var one: UIButton! @IBOutlet weak var two: UIButton! @IBOutlet weak var three: UIButton! @IBOutlet weak var kekka: UILabel! @IBOutlet weak var agote: UILabel! var basu = 0 var teto = 0 override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } @IBAction func starta(sender: AnyObject) { teto = 3 kekka.text = String(teto) agote.text = String(teto) } @IBAction func onea(sender: AnyObject) { teto = teto + 1 kekka.text = String(teto) } }

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

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

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

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

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

guest

回答1

0

ベストアンサー

たぶん、誤ってStoryboardから
@IBOutlet weak var onea: UIButton!
というプロパティをアウトレット接続で作成し、途中で誤りに気がついてそのコードは削除したんだけど、Storyboard側の接続が削除されてないので、Storyboardから二つ目の画面をロードする際に、接続先として登録されたままになっているoneaというプロパティが見つからなくてクラッシュしたんじゃないかなと推測します。

Storyboardに貼り付けた各部品の「Referencing Outlets」の設定を一度全部見直し、他にも不要な接続が残っていないか確認してみることをお勧めします。

投稿2016/06/04 02:16

編集2016/06/04 02:40
TakeOne

総合スコア6299

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問