2017-08-20 9 views
0

私はチュートリアルに従います。ボタンをクリックするたびに、スレッド1の信号であるAppDelegate.swiftにエラーが発生します。SIGABRTSwift:スレッド1シグナルSIGABRTクラスのAppDelegate:UIResponder、UIApplicationDelegate

import UIKit 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { //Thread 1 signal SIGABRT 

ここに私のストーリーボードのスクリーンショットがあります。 enter image description here

私はすべての上に見ていると、いくつかの答えは存在しないIBOutletの接続を参照していますが、スクリーンショットで見ることができるようにすべての私の接続はので、私は問題が何であるかを知らない良く見えます。

ここに私のviewController.swiftコードです: 輸入のUIKit

クラスのViewController:のUIViewController {

@IBOutlet weak var input: UITextField! 
@IBOutlet weak var label: UILabel! 

@IBAction func button(_ sender: UIButton) { 
    label.text = input.text 
    UserDefaults.standard.set(input, forKey: "myName") 
    input.text = " " 
} 

override func viewDidLoad() { 
    super.viewDidLoad() 
} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
} 

override func viewDidAppear(_ animated: Bool) { 
    if let x = UserDefaults.standard.object(forKey: "myName") as? String{ 
     label.text = x 
    } 
} 

}

は、ここで私がクリックしたときに私が取得、完全なエラーメッセージだが、ボタン: 2017-08-20 23:29:09.155350 + 0800 asd [2297:997880] [LayoutConstraints] Un同時に制約を満たすことができる。 おそらく、次のリストの制約の少なくとも1つは、あなたが望まないものです。 これを試してください: (1)それぞれの制約を見て、あなたが期待していないものを見つけようとしてください。 (2)不要な制約を追加したコードを見つけて修正します。 ( "< _UILayoutSupportConstraint:0x608000284d30 _UILayoutGuide:0x7fc28340be50.height == 20(アクティブ)>"、 "< _UILayoutSupportConstraint:0x608000283980 V:| - (0) - [_ UILayoutGuide:0x7fc28340be50](アクティブ、名称: '|': UIViewの:0x7fc28340b780)>」、 "< _UILayoutSupportConstraint:0x608000284dd0 _UILayoutGuide:0x7fc28340c420.height == 0(アクティブ)>"、 "< _UILayoutSupportConstraint:0x608000284d80 _UILayoutGuide:0x7fc28340c420.bottom ==のUIView:0x7fc28340b780.bottom(アクティブ)>" 、 ""、 ""、 ""、 ""、 ""、 ""、 ""、 「」 )

は制約

を破って回復を試みますデバッガでこれをキャッチするUIViewAlertForUnsatisfiableConstraintsでシンボリックブレークポイントを作成します。 UIViewのUIConstraintBasedLayoutDebuggingカテゴリのメソッドも参考になる場合があります。 2017-08-20 23:29:11.137163 + 0800 asd [2297:997880] [MC] systemgroup.com.apple.configurationprofilesのシステムグループコンテナは/ Users/Myeongjeon/Library/Developer/CoreSimulator/Devices/200D40A8- EFD4-4FE9-8E13-37C2E7D86BA6/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 2017-08-20 23:29:11.137610 + 0800 asd [2297:997880] [MC]私的有効ユーザーからの読書設定。 2017-08-20 23:29:15.719443 + 0800 asd [2297:997880] [User Defaults]プロパティリスト以外のオブジェクトを設定しようとしました。 layer =>キーmyNameのNSUserDefaults/CFPreferences値として 2017-08-20 23:29:15。723 asd [2297:997880] *キャッチされていない例外 'NSInvalidArgumentException'のためアプリを終了しています。理由: 'プロパティ以外のリストオブジェクトを挿入しようとしました。層=>キーがmyName」 用*まずスローコールスタック: ( 0 CoreFoundationの0x0000000103725b0b exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010318a141 objc_exception_throw + 48 2 CoreFoundationの0x000000010378e625 + [NSExceptionレイズ:フォーマット:] + 197 3 CoreFoundationの0x0000000103678729 _CFPrefsValidateValueForKey + 249 4 CoreFoundationのを0x00000001036e5afc - [CFPrefsPlistSource sendMessageSettingValue:forKey:] + 572 5 CoreFoundationのを0x000000010378fdaa - [CFPrefsPlistSource alreadylocked_setValues:forKeys:カウント:] + 794 6 CoreFoundationの0x000000010374cc58を - [CFPrefsSource setValues:forKeys:カウント: removeValuesForキーは:カウント:] + 264 7 CoreFoundationの0x0000000103678620 - [CFPrefsSource setValues:forKeys:カウント:] + 32 8 CoreFoundationの0x0000000103786af6 - [CFPrefsSearchListSource alreadylocked_setValues:forKeys:カウント:] + 454 9 CoreFoundationの0x000000010374cc58 - [CFPrefsSource setValues:forKeys:カウント:removeValuesForKeys:カウント:] + 264 10 CoreFoundationの0x0000000103678620 - [CFPrefsSource setValues:forKeys:カウント:] + 32 11 CoreFoundationの0x00000001036bbfe9 - [CFPrefsSourceのsetValue:forKey:] + 57 12 CoreFoundationの0x0000000103788a4f __108 - [_ CFXPreferences(SearchListAdditions) withSearchListForIdentifier:コンテナ:cloudConfigurationURL:perform:] _ block_invoke + 319 13 CoreFoundation 0x000000010378824d normalizeクイーンプレット+ 317 14 CoreFoundationの0x0000000103788909 - [_ CFXPreferences(SearchListAdditions)withSearchListForIdentifier:容器:cloudConfigurationURL:実行:] + 105 15 CoreFoundationの0x0000000103772c15 - [_ CFXPreferencesのsetValue:forKey:appIdentifier:容器:configurationURL:] + 261 16 CoreFoundationの0x00000001036bbf34 _CFPreferencesSetAppValueWithContainer + 68 17基礎0x0000000102c89790 - [NSUserDefaults(NSUserDefaults)のsetObject:forKey:] + 55 18 ASD 0x0000000102bafc51 TFC3asd14ViewController6buttonfCSo8UIButtonT + 1073 19 ASDの0x0000000102baff6a TToFC3asd14ViewController6buttonfCSo8UIButtonT + 58 20のUIKit 0x0000000103b4ad82 - 【のUIApplication sendAction:に:から:forEvent:] + 83 21のUIKit 0x0000000103ccf5ac - [するuicontrol sendAction:全forEvent:] + 67 22のUIKit 0x0000000103ccf8c7 - [するuicontrol _sendActionsForEvents:withEvent:] + 450 23のUIKit 0x0000000103cce802 - [するuicontrol touchesEnded:withEvent:] + 618 24のUIKit 0x0000000103bb87ea - [UIWindow _sendTouchesForEvent:] + 2707 25のUIKit 0x0000000103bb9f00 - [UIWindowのSendEvent:] + 4114 26のUIKit 0x0000000103b66a84 - [のUIApplicationのSendEvent:] + 352 27のUIKit 0x000000010434a5d4 __dispatchPreprocessedEventFromEventQueue + 2926 28 UIKit 0x0000000104342532 __handleEventQueue + 1122 29 CoreFoundation 0x00000001036cbc01 __CFRUNLOOP_IS _CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 30 CoreFoundationの0x00000001036b10cf __CFRunLoopDoSources0 + 527 31 CoreFoundationの0x00000001036b05ff __CFRunLoopRun + 911 32 CoreFoundationの0x00000001036b0016 CFRunLoopRunSpecific + 406 33 GraphicsServices 0x0000000107d05a24 GSEventRunModal + 62 34のUIKit 0x0000000103b49134 UIApplicationMain 36 55 + + 159 35 ASD 0x0000000102bb1927主libdyld。 dylib 0x0000000106d9a65d start + 1 ) libC++ abi。dylib:あなたのコードと批判的に間違って何種類NSException

+0

あなたのストーリーボードには何も接続されていない、あなたのビューコントローラにはおそらく '@ IBOutlet'変数があります。 –

+0

詳細情報を取得するには、ブレークポイントナビゲータ(⌘7)で例外ブレークポイントを設定します。 – vadian

+0

@TristanBeaton私はビューコントローラに3つのIBOutlet変数しかなく、スクリーンショットで見ることができるように3つのIBOutlet変数がすべて正しく接続されています –

答えて

0

のキャッチされない例外で終了するが、ここにある:

@IBOutlet weak var input: UITextField! 

@IBAction func button(_ sender: UIButton) { 
    label.text = input.text 
    UserDefaults.standard.set(input, forKey: "myName") 
    input.text = " " 
} 

あなたは標準UserDefaultsinputを保存しようとしているが、inputUITextFieldです。 UITextFieldUserDefaultsに保存することはできません。

はたぶん、あなたはこのような何かをしたい:

@IBAction func button(_ sender: UIButton) { 
    label.text = input.text 
    UserDefaults.standard.set(input.text ?? "", forKey: "myName") 
    input.text = " " 
} 

あなたのデバッグ出力の中で最も重要な部分:アプリを終了

により、理由「NSInvalidArgumentException」キャッチされない例外へ:「試みを非プロパティリストオブジェクトを挿入する。層は=>キーがmyName」

のためにあなたのコードがキーmyNameの無効な値を設定しようとしていることを言っています。

あなたのコードとストーリーボードの設定を修正する必要があるかもしれないが、クラッシュの原因ではないことを示すメッセージが表示されます。

関連する問題