Korne127
Korne127

Reputation: 332

Thread 1 signal SIGABRT Error in Xcode [Swift]

When I want to make an UITableView inside of an ViewController. I have made all exactly as in a tutorial in which it worked, but I got this Error "Thread one signal SIGABRT" on class AppDelegate: UIResponder, UIApplicationDelegate { in AppDelegate.swift. I have recently asked this question with all codes before, but every answer said, they need more information.

So i have made the whole Xcode Project new and I have filmed it with Screenium. Here is the video (10 minutes; 53 Megabyte) https://workupload.com/file/24NNW68. You must give in the Password

ThePassword

Then there is the information of the "video.mov". Click on the below (blue) download, the abowe is advertising.

For people who don't want to see the video (I've made it when I was 14, so my voice is a bit high: Here is the complete code:

AppDelegate.swift:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // 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.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // 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.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // 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.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // 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.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}

ViewController.swift

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    @IBOutlet weak var tableView: UITableView!
    var Label1multi = ["TableView","Alarm Clock","Green","Book"]
    var Label2multi = ["Pen", "1 Euro","Red","Mobile Phone"]
    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.
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 4
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! THISTableViewCell
        cell.Label1.text = Label1multi[indexPath.row]
        cell.Label2.text = Label2multi[indexPath.row]
        return cell
    }

}

THISTableViewCell.swift:

import UIKit

class THISTableViewCell: UITableViewCell {

    @IBOutlet weak var Label1: UILabel!
    @IBOutlet weak var Label2: UILabel!

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}

But I've found the failure: When I remove The Outlet TableView - DataSource I don't get the error, but I only get empty cells in the TableView.

Upvotes: 1

Views: 857

Answers (1)

Magnas
Magnas

Reputation: 4054

I have watched your video. I think the mistake is a small one. You need to set the reuse identifier for your custom cell to be "cell" in the attributes inspector. You use it correctly in this method:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! THISTableViewCell
    cell.Label1.text = Label1multi[indexPath.row]
    cell.Label2.text = Label2multi[indexPath.row]
    return cell
}

Select the cell in main.storyboard and select the attributes inspector. Enter "cell" in the "identifier" box.

Upvotes: 1

Related Questions