线程1:信号SIGABRT - 问题是什么?

时间:2017-01-04 22:55:05

标签: ios xcode swift2

我是编程的初学者,也是Stack Overflow的新手。我还在弄清楚代码和网站是如何工作的,所以如果我没有正确使用它们,我很抱歉。 (我不是英语母语人士,但我会尽力解释我的问题)

所以,我正在为我的学校项目建立一个待办事项列表应用程序,但它并没有很好地运作。我没有任何红色警告标记,但是当我运行模拟器并单击"添加按钮"时,它会停止运行并返回到代码文件。在那里,我看到"线程1:信号SIGABRT"在AppDelegate.swift中。

控制台中的消息是:

2017-01-06 20:14:30.057054 To-Do-List [61234:3241731] [MC] systemgroup.com.apple.configurationprofiles路径的系统组容器是/ Users / mikinatanaka / Library / Developer / CoreSimulator /设备/ 27DCECFA-4E53-4C94-9985-2D4BBA9575CE /数据/容器/共享/ SystemGroup / systemgroup.com.apple.configurationprofiles 2017-01-06 20:14:30.058241待办事项列表[61234:3241731] [MC]从私人有效用户设置中读取。 2017-01-06 20:14:32.392577待办事项列表[61234:3241836] 0x600000548cf0复制匹配资产回复:XPC_TYPE_DICTIONARY {count = 1,transaction:0,voucher = 0x0,contents =     "结果" => :29 } 2017-01-06 20:14:32.393567 To-Do-List [61234:3241836] 0x6080003406e0守护进程配置查询回复:XPC_TYPE_DICTIONARY {count = 2,transaction:0,voucher = 0x0,contents =     "字典" => {count = 1,transaction:0,voucher = 0x0,contents =         " SERVERURL" => {count = 3,transaction:0,voucher = 0x0,contents =             " com.apple.CFURL.magic" => C3853DCC-9776-4114-B6C1,FD9F51944A6D             " com.apple.CFURL.string" => {length = 30,contents =" https://mesu.apple.com/assets/" }             " com.apple.CFURL.base" => :null-object         }     }     "结果" => :0 }

2017-01-06 20:14:32.394060 To-Do-List[61234:3241836] [MobileAssetError:29] Unable to copy asset information from https://mesu.apple.com/assets/ for asset type com.apple.MobileAsset.TextInput.SpellChecker
2017-01-06 20:14:37.185 To-Do-List[61234:3241731] -[To_Do_List.AddToDo addItemWithSender:]: unrecognized selector sent to instance 0x7fc5184025d0
2017-01-06 20:14:37.320 To-Do-List[61234:3241731] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[To_Do_List.AddToDo addItemWithSender:]: unrecognized selector sent to instance 0x7fc5184025d0'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000106ec234b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010692321e objc_exception_throw + 48
    2   CoreFoundation                      0x0000000106f31f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x0000000106e47c15 ___forwarding___ + 1013
    4   CoreFoundation                      0x0000000106e47798 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x00000001072e75b8 -[UIApplication sendAction:to:from:forEvent:] + 83
    6   UIKit                               0x000000010746cedd -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x000000010746d1f6 -[UIControl _sendActionsForEvents:withEvent:] + 444
    8   UIKit                               0x000000010746c0f2 -[UIControl touchesEnded:withEvent:] + 668
    9   UIKit                               0x0000000107354ce1 -[UIWindow _sendTouchesForEvent:] + 2747
    10  UIKit                               0x00000001073563cf -[UIWindow sendEvent:] + 4011
    11  UIKit                               0x000000010730363f -[UIApplication sendEvent:] + 371
    12  UIKit                               0x0000000107af571d __dispatchPreprocessedEventFromEventQueue + 3248
    13  UIKit                               0x0000000107aee3c7 __handleEventQueue + 4879
    14  CoreFoundation                      0x0000000106e67311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x0000000106e4c59c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x0000000106e4ba86 __CFRunLoopRun + 918
    17  CoreFoundation                      0x0000000106e4b494 CFRunLoopRunSpecific + 420
    18  GraphicsServices                    0x000000010b4c4a6f GSEventRunModal + 161
    19  UIKit                               0x00000001072e5964 UIApplicationMain + 159
    20  To-Do-List                          0x00000001063415df main + 111
    21  libdyld.dylib                       0x000000010a53c68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

这个错误是什么意思?我该如何解决?

我知道这是基本问题,但我读了很多文章后我无法理解。

在某些文章中,他们说由于View Controller中的连接错误而发生错误。这样对吗?我检查了所有连接,但我没有看到任何连接错误。

请给我一些帮助来解决错误!非常感谢你。

我正在使用Xcode版本8.1和Swift 2.0。我复制并粘贴了以下代码:

ViewController.swift

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var todolistTable: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        func viewDidLoad() {
                if UserDefaults.standard.object(forKey: "todoList") != nil {
                todoItem = UserDefaults.standard.object(forKey: "todoList") as! [String]
            }
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return todoItem.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cellValue = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "cell")
        cellValue .textLabel?.text = todoItem[indexPath.row]
        return cellValue
    }

    func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath){
        if editingStyle == UITableViewCellEditingStyle.delete{
            todoItem.remove(at: indexPath.row)
            UserDefaults.standard.set(todoItem, forKey: "todoList")
            todolistTable.reloadData()
        }
    }

    override func viewDidAppear(_ animated: Bool) {
        todolistTable.reloadData()
    }


}

AddToDo.swift

import UIKit

var todoItem = [String]()

class AddToDo: UIViewController {

    @IBOutlet weak var itemText: UITextField!

    @IBAction func addItem(sender: AnyObject) {
        todoItem.append(itemText.text!)
        itemText.text = ""
        UserDefaults.standard.set(todoItem, forKey: "todoList")
    }

    override func viewDidLoad() {
        super.viewDidLoad()

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

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func textFieldShouldReturn(textField: UITextField!) -> Bool {
        itemText.resignFirstResponder()
        return true
    }


    /*
    // 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.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

0 个答案:

没有答案