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

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

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

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

Q&A

解決済

1回答

486閲覧

Thread 1: signal SIGABRT エラーの対応

harago

総合スコア11

Swift

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

0グッド

0クリップ

投稿2019/06/20 00:53

編集2019/06/20 11:07

前提・実現したいこと

Xcodeでswiftを書いているのですが、複数の画面を作り、画面遷移させようとするとトップ→Aページは成功するが。
Aページ→Bページやトップ→Bページへの遷移時画面が固まりエラーになる。
かなり初心者ですので咀嚼してご教示いただけると幸いです。

発生している問題・エラーメッセージ

2019-06-20 17:08:11.317438+0900 projects4[29808:2183954] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<projects4.DetailViewController2 0x7fb57850fae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key testImage7.' *** First throw call stack: ( 0 CoreFoundation 0x000000010d8866fb __exceptionPreprocess + 331 1 libobjc.A.dylib 0x000000010bea0ac5 objc_exception_throw + 48 2 CoreFoundation 0x000000010d886269 -[NSException raise] + 9 3 Foundation 0x000000010b915562 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 289 4 UIKitCore 0x000000010fb132d2 -[UIViewController setValue:forKey:] + 87 5 UIKitCore 0x000000010fda08fd -[UIRuntimeOutletConnection connect] + 109 6 CoreFoundation 0x000000010d872d41 -[NSArray makeObjectsPerformSelector:] + 305 7 UIKitCore 0x000000010fd9d643 -[UINib instantiateWithOwner:options:] + 1810 8 UIKitCore 0x000000010fb1a3af -[UIViewController _loadViewFromNibNamed:bundle:] + 382 9 UIKitCore 0x000000010fb1ad39 -[UIViewController loadView] + 177 10 UIKitCore 0x000000010fb1b048 -[UIViewController loadViewIfRequired] + 172 11 UIKitCore 0x000000010fb1b868 -[UIViewController view] + 27 12 UIKitCore 0x000000010fa430fc -[_UIFullscreenPresentationController _setPresentedViewController:] + 89 13 UIKitCore 0x000000010fa371f2 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133 14 UIKitCore 0x000000010fb2e4ce -[UIViewController _presentViewController:withAnimationController:completion:] + 3700 15 UIKitCore 0x000000010fb3111b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98 16 UIKitCore 0x000000010fb31633 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511 17 UIKitCore 0x000000010fb31082 -[UIViewController _presentViewController:animated:completion:] + 172 18 UIKitCore 0x000000010fb312e0 -[UIViewController presentViewController:animated:completion:] + 150 19 UIKitCore 0x00000001102b1eae __74-[UIStoryboardPresentationSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 133 20 UIKitCore 0x00000001102b6b9f -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 276 21 UIKitCore 0x00000001102b6a5d -[UIStoryboardSegueTemplate _perform:] + 82 22 UIKitCore 0x00000001102b6d1f -[UIStoryboardSegueTemplate perform:] + 157 23 UIKitCore 0x000000011011f204 -[UIApplication sendAction:to:from:forEvent:] + 83 24 UIKitCore 0x000000010fb74c19 -[UIControl sendAction:to:forEvent:] + 67 25 UIKitCore 0x000000010fb74f36 -[UIControl _sendActionsForEvents:withEvent:] + 450 26 UIKitCore 0x000000010fb73eec -[UIControl touchesEnded:withEvent:] + 583 27 UIKitCore 0x0000000110157eee -[UIWindow _sendTouchesForEvent:] + 2547 28 UIKitCore 0x00000001101595d2 -[UIWindow sendEvent:] + 4079 29 UIKitCore 0x0000000110137d16 -[UIApplication sendEvent:] + 356 30 UIKitCore 0x0000000110208293 __dispatchPreprocessedEventFromEventQueue + 3232 31 UIKitCore 0x000000011020abb9 __handleEventQueueInternal + 5911 32 CoreFoundation 0x000000010d7edbe1 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 33 CoreFoundation 0x000000010d7ed463 __CFRunLoopDoSources0 + 243 34 CoreFoundation 0x000000010d7e7b1f __CFRunLoopRun + 1231 35 CoreFoundation 0x000000010d7e7302 CFRunLoopRunSpecific + 626 36 GraphicsServices 0x000000011596c2fe GSEventRunModal + 65 37 UIKitCore 0x000000011011dba2 UIApplicationMain + 140 38 projects4 0x000000010b5bb3db main + 75 39 libdyld.dylib 0x000000010ec8e541 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

該当のソースコード

swift

1// 2// AppDelegate.swift 3// projects4 4// 5// Created by jiraffe40035 on 2019/06/16. 6// Copyright © 2019 jiraffe40035. All rights reserved. 7// 8//@UIApplicationMain追加した 9import UIKit 10 @UIApplicationMain 11 12class AppDelegate:UIResponder,UIApplicationDelegate { 13 14 var window: UIWindow? 15 16 17 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 // Override point for customization after application launch. 19 return true 20 } 21 22 func applicationWillResignActive(_ application: UIApplication) { 23 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 } 26 27 func applicationDidEnterBackground(_ application: UIApplication) { 28 // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 } 31 32 func applicationWillEnterForeground(_ application: UIApplication) { 33 // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 } 35 36 func applicationDidBecomeActive(_ application: UIApplication) { 37 // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 } 39 40 func applicationWillTerminate(_ application: UIApplication) { 41 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42} 43 44} 45

DetailViewController2 のソースコード

//
// DetailViewController2.swift
// projects4
//
// Created by jiraffe40035 on 2019/06/17.
// Copyright © 2019 jiraffe40035. All rights reserved.
//

import UIKit

class DetailViewController2: UIViewController {

@IBOutlet weak var tappedButton: UIImageView!

override func prepare (for segue: UIStoryboardSegue,sender: Any?){
//遷移先のDetailViewController2を取得
let detavilViewController2 = segue.destination as! DetailViewController2
//タップされたボタンを要素を取得
_ = sender as! UIButton;
//ボタンタグを取得
let buttonTag = tappedButton.tag
//詳細画面に表示する画像名を生成
let detailImageName = "image" + String(buttonTag)
//詳細画面に画像名を渡す
detavilViewController2.imageName = detailImageName
}

@IBOutlet weak var detailImageView2: UIImageView!

//①追記
var imageName:String?

override func viewDidLoad() {
super.viewDidLoad()

//②更新
guard let myImageName = imageName else{
return
}

//myImageNameを用いて画像を指定
detailImageView2.image = UIImage (named:myImageName)
}
//追記
//detailImageView2.image = UIImage (named: “image7")

// Do any additional setup after loading the view.
}

/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/

補足情報(FW/ツールのバージョンなど)

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

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

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

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

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

MasakiHori

2019/06/20 04:51

エディタ下部のコンソールに表示されているエラーをすべて追記してください。
harago

2019/06/20 08:08

2019-06-20 17:08:11.317438+0900 projects4[29808:2183954] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<projects4.DetailViewController2 0x7fb57850fae0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key testImage7.' *** First throw call stack: ( 0 CoreFoundation 0x000000010d8866fb __exceptionPreprocess + 331 1 libobjc.A.dylib 0x000000010bea0ac5 objc_exception_throw + 48 2 CoreFoundation 0x000000010d886269 -[NSException raise] + 9 3 Foundation 0x000000010b915562 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 289 4 UIKitCore 0x000000010fb132d2 -[UIViewController setValue:forKey:] + 87 5 UIKitCore 0x000000010fda08fd -[UIRuntimeOutletConnection connect] + 109 6 CoreFoundation 0x000000010d872d41 -[NSArray makeObjectsPerformSelector:] + 305 7 UIKitCore 0x000000010fd9d643 -[UINib instantiateWithOwner:options:] + 1810 8 UIKitCore 0x000000010fb1a3af -[UIViewController _loadViewFromNibNamed:bundle:] + 382 9 UIKitCore 0x000000010fb1ad39 -[UIViewController loadView] + 177 10 UIKitCore 0x000000010fb1b048 -[UIViewController loadViewIfRequired] + 172 11 UIKitCore 0x000000010fb1b868 -[UIViewController view] + 27 12 UIKitCore 0x000000010fa430fc -[_UIFullscreenPresentationController _setPresentedViewController:] + 89 13 UIKitCore 0x000000010fa371f2 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133 14 UIKitCore 0x000000010fb2e4ce -[UIViewController _presentViewController:withAnimationController:completion:] + 3700 15 UIKitCore 0x000000010fb3111b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98 16 UIKitCore 0x000000010fb31633 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511 17 UIKitCore 0x000000010fb31082 -[UIViewController _presentViewController:animated:completion:] + 172 18 UIKitCore 0x000000010fb312e0 -[UIViewController presentViewController:animated:completion:] + 150 19 UIKitCore 0x00000001102b1eae __74-[UIStoryboardPresentationSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 133 20 UIKitCore 0x00000001102b6b9f -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 276 21 UIKitCore 0x00000001102b6a5d -[UIStoryboardSegueTemplate _perform:] + 82 22 UIKitCore 0x00000001102b6d1f -[UIStoryboardSegueTemplate perform:] + 157 23 UIKitCore 0x000000011011f204 -[UIApplication sendAction:to:from:forEvent:] + 83 24 UIKitCore 0x000000010fb74c19 -[UIControl sendAction:to:forEvent:] + 67 25 UIKitCore 0x000000010fb74f36 -[UIControl _sendActionsForEvents:withEvent:] + 450 26 UIKitCore 0x000000010fb73eec -[UIControl touchesEnded:withEvent:] + 583 27 UIKitCore 0x0000000110157eee -[UIWindow _sendTouchesForEvent:] + 2547 28 UIKitCore 0x00000001101595d2 -[UIWindow sendEvent:] + 4079 29 UIKitCore 0x0000000110137d16 -[UIApplication sendEvent:] + 356 30 UIKitCore 0x0000000110208293 __dispatchPreprocessedEventFromEventQueue + 3232 31 UIKitCore 0x000000011020abb9 __handleEventQueueInternal + 5911 32 CoreFoundation 0x000000010d7edbe1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 33 CoreFoundation 0x000000010d7ed463 __CFRunLoopDoSources0 + 243 34 CoreFoundation 0x000000010d7e7b1f __CFRunLoopRun + 1231 35 CoreFoundation 0x000000010d7e7302 CFRunLoopRunSpecific + 626 36 GraphicsServices 0x000000011596c2fe GSEventRunModal + 65 37 UIKitCore 0x000000011011dba2 UIApplicationMain + 140 38 projects4 0x000000010b5bb3db main + 75 39 libdyld.dylib 0x000000010ec8e541 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
harago

2019/06/20 08:08

こちらになります。 ご確認お願いします!
MasakiHori

2019/06/20 08:45

他の人にもすぐに見れるように質問を編集して追加してください
MasakiHori

2019/06/20 08:46

可能であればDetailViewController2 の内容も追記してください
harago

2019/06/20 08:56

DetailViewController2 の追加はソースコードで問題ないですか? あとエディタ下部のエラー内容質問の中に追記しました。
dsuzuki

2019/06/20 09:07

DetailViewController2 の testImage7 について、ソースコードとstoryboardのoutlet接続が途切れていませんか。 私の場合、Outlet接続した後にソースコード上のプロパティを消したままの(storyboard上にリンク情報が残っている)状態で実行して、類似の事象が発生しました。
harago

2019/06/20 10:19

// // DetailViewController2.swift // projects4 // // Created by jiraffe40035 on 2019/06/17. // Copyright © 2019 jiraffe40035. All rights reserved. // import UIKit class DetailViewController2: UIViewController { @IBOutlet weak var tappedButton: UIImageView! override func prepare (for segue: UIStoryboardSegue,sender: Any?){ //遷移先のDetailViewController2を取得 let detavilViewController2 = segue.destination as! DetailViewController2 //タップされたボタンを要素を取得 _ = sender as! UIButton; //ボタンタグを取得 let buttonTag = tappedButton.tag //詳細画面に表示する画像名を生成 let detailImageName = "image" + String(buttonTag) //詳細画面に画像名を渡す detavilViewController2.imageName = detailImageName } @IBOutlet weak var detailImageView2: UIImageView! //①追記 var imageName:String? override func viewDidLoad() { super.viewDidLoad() //②更新 guard let myImageName = imageName else{ return } //myImageNameを用いて画像を指定 detailImageView2.image = UIImage (named:myImageName) } //追記 //detailImageView2.image = UIImage (named: “image7") // Do any additional setup after loading the view. } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */
harago

2019/06/20 10:20

DetailViewController2 のソースコードになります。 どこを修正すれば良いのでしょうか?
dsuzuki

2019/06/20 10:35

※コードは質問欄に記載してください。 私のケースに当てはめれば、DetailViewController2に対応するstoryboard上に(DetailViewController2には既にない)testImage7というプロパティへのOutletのリンクが残っていませんか?ということです。 つまり、ソースコードではなく、storyboardを確認してください。
harago

2019/06/20 12:02

残っていないと思われます どうするべきなんでしょうか。。。
dsuzuki

2019/06/20 12:05

testImage7を全文検索(cmd + shift + f)して、どこかに残っていないか確認してください。
harago

2019/06/20 12:05

一つの画面では遷移してくれるのですが、他のボタンから別の画面に遷移する時に落ちます。。。
harago

2019/06/20 12:08

class AppDelegate:UIResponder,UIApplicationDelegate { Thread 1: signal SIGABRT このエラーが永遠に解決しないです。
harago

2019/06/20 12:12

すみません。 解決しました。 本当にありがとうございました!
dsuzuki

2019/06/20 12:15

解決した内容を回答欄に記載して、解決済みとしてください。
guest

回答1

0

自己解決

storyboardを編集して解決済み

投稿2019/06/20 12:22

harago

総合スコア11

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

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

dsuzuki

2019/06/20 12:42

できれば、今後同じ問題を抱えた人のために、詳細な記載をお願いします。 (既に存在しない)testImage7を全文検索(cmd + shift + f)して、いずれかのstoryboardに残っていたということでしょうか
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問