Throwing my Mac out the window

Discussion in 'iOS Programming' started by FasterThanLlamas, Feb 26, 2016.

  1. FasterThanLlamas macrumors newbie

    Joined:
    Feb 26, 2016
    #1
    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.
    
        }
    
    }
     
  2. Dookieman macrumors 6502

    Joined:
    Oct 12, 2009
    #2
    I haven't looked very closely but I noticed that you don't have a space in these lines. Could that be your problem? Assuming you did copy/paste exactly.
     
  3. FasterThanLlamas thread starter macrumors newbie

    Joined:
    Feb 26, 2016
    #3
    Yes, there are spaces. Not sure why it didn't paste.
     
  4. Dookieman macrumors 6502

    Joined:
    Oct 12, 2009
    #4
    Does your app crash immediately when you run it?
     
  5. FasterThanLlamas thread starter macrumors newbie

    Joined:
    Feb 26, 2016
    #5
    Build succeeded then:

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

    (lldb)
     
  6. Dookieman macrumors 6502

    Joined:
    Oct 12, 2009
    #6
    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.
     
  7. AxoNeuron macrumors 65816

    AxoNeuron

    Joined:
    Apr 22, 2012
    Location:
    The Left Coast
    #7
    Have you included any libraries/frameworks in your project?
     
  8. FasterThanLlamas thread starter macrumors newbie

    Joined:
    Feb 26, 2016
    #8
    Haha I've done that about 50 times.
    --- Post Merged, Feb 26, 2016 ---
    Brand new projects from scratch every time.
     
  9. tyche macrumors 6502

    Joined:
    Jul 30, 2010
    #9
    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.
     
  10. Dookieman macrumors 6502

    Joined:
    Oct 12, 2009
    #10
    I would suggest this. Nothing in your code looks incorrect and there could be some underlying settings that aren't working properly.
     
  11. tyche macrumors 6502

    Joined:
    Jul 30, 2010
    #11
    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.
     
  12. FasterThanLlamas thread starter macrumors newbie

    Joined:
    Feb 26, 2016
    #12
    Thanks for the help everyone. Reinstalled Xcode and we appear to be back in business. If it reverts, I'll post again.
     

Share This Page