Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

FasterThanLlamas

macrumors newbie
Original poster
Feb 26, 2016
5
0
Thanks in advance for the help.

Total noob here trying to figure out
Code:
UITableView
and I keep getting an error that has me completely stumped.

Code:
AppDelegate.swift
keeps returning a
Code:
Thread 1: signal SIGABRT
error on
Code:
class AppDelegate: UIResponder, UIApplicationDelegate
and I can't possibly figure out what the problem is after days of searching. Code below.

Code:
AppDelegate.swift

Code:
import UIKit


@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate {


    var window: UIWindow?



    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        returntrue

    }


    func applicationWillResignActive(application: UIApplication) {

    }


    func applicationDidEnterBackground(application: UIApplication) {

    }


    func applicationWillEnterForeground(application: UIApplication) {

    }


    func applicationDidBecomeActive(application: UIApplication) {

    }


    func applicationWillTerminate(application: UIApplication) {

    }

}

Code:
 ViewController.swift

Code:
import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    var cellContent = ["1", "2", "3", "4"]

    @IBOutletweakvar tableView : UITableView!

    overridefunc viewDidLoad() {

        super.viewDidLoad()

        tableView.delegate = self      

        tableView.dataSource = self

    }   

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 

        returncellContent.count

    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

        let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")

        cell.textLabel?.text = cellContent[indexPath.row]

        return cell

    }

    overridefunc didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

}
 
Build succeeded then:

libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb)
Weird. Everything looks correct, besides the missing spaces in some cases. I even copied and pasted your code into a new project and it worked for me. Try creating a new project and reuse the code.
 
Weird. Everything looks correct, besides the missing spaces in some cases. I even copied and pasted your code into a new project and it worked for me. Try creating a new project and reuse the code.
Haha I've done that about 50 times.
[doublepost=1456510998][/doublepost]
Have you included any libraries/frameworks in your project?
Brand new projects from scratch every time.
 
If your storyboard tableview cell's reusableidentifier called "Cell"?

I would create a new single view application, build and run to verify your xcode is setup.
 
If your storyboard tableview cell's reusableidentifier called "Cell"?

I would create a new single view application, build and run to verify your xcode is setup.

I would suggest this. Nothing in your code looks incorrect and there could be some underlying settings that aren't working properly.
 
I tried the code and it works. I tried removing things and Swift/iOS is much more forgiving than I would have assumed. The only way I can get it to crash is if the @IBOutlet isn't attached to the storyboard.
 
Thanks for the help everyone. Reinstalled Xcode and we appear to be back in business. If it reverts, I'll post again.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.