0

Issue

I am using Xcode 10, Swift 5. I tried to rename some variables and arrays. I changed them all back to the original name though. After I did this my tab bar button throws an error at AppDelegate: Thread 1: signal SIGABRT

console output:

2019-05-23 12:46:56.511809-0400 DIY Home Repair[1958:326215] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key videoImageView.' * First throw call stack: (0x1d8b30518 0x1d7d0b9f8 0x1d8a4dec0 0x1d94b5a00 0x2054fb6fc 0x204d31324 0x1d8a1df38 0x204d2df7c 0x2052753a4 0x104560b80 0x104560d7c 0x20528ea38 0x20528ef38 0x20525b740 0x205278a60 0x2054fbe54 0x1dcfbe1f0 0x1dcfc3198 0x2054e7e88 0x204a3abe4 0x204a35478 0x204a33744 0x2054b8994 0x2054b8c50 0x2054c6758 0x2054c2360 0x2054b86d8 0x204a3b9e8 0x204a3bf7c 0x204a3d210 0x204a20420 0x2054fbe54 0x1dcfbe1f0 0x1dcfc3198 0x1dcf260a8 0x1dcf54108 0x1dcf54cf8 0x1d8ac189c 0x1d8abc5c4 0x1d8abcb40 0x1d8abc354 0x1dacbc79c 0x205073b68 0x10455d750 0x1d85828e0) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

Attempting to solve issue

I checked all of my segues, class names - they match controllers. I checked all of the code to ensure all the variables and arrays are accurate. I deleted the segue from the rootTabBarController to the ViewController and reconnected. I commented out all of the code to see if there was something in the viewController that was throwing this error. I cleaned the build folder and restarted Xcode. None of this worked.

Code for the viewController

Keep in mind, I commented this all out and added a blank viewDidLoad func. It still threw the NSExeption.

import UIKit

class ProductViewController: UIViewController {

    @IBOutlet weak var tableView: UITableView!

     var videos: [Video] = []

     override func viewDidLoad() {
        super.viewDidLoad()
        videos = Video.createVideoArray()
     }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

         if segue.identifier == "MasterToDetail" {
            let destVC = segue.destination as! DetailViewController
            destVC.video = sender as? Video
         }
     }
}

extension ProductViewController: UITableViewDelegate, UITableViewDataSource {

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

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let video = videos[indexPath.row]

    let cell = tableView.dequeueReusableCell(withIdentifier: "VideoCell") as! VideoCell
    cell.setVideo(video: video)

    return cell
}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let video = videos[indexPath.row]
    performSegue(withIdentifier: "MasterToDetail", sender: video)
}
override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}
}

enter image description here

  • Can't see any tab bar button in the code you posted – Rico Crescenzio May 23 '19 at 16:12
  • Its done through storyboard, the button just presents the viewController, its code posted above. –  May 23 '19 at 16:14
  • 1
    So maybe it's missing the `IBOutlet` of that tab bar button item? – Rico Crescenzio May 23 '19 at 16:15
  • Forgive my ignorance, but how do i check that in storyboard? –  May 23 '19 at 16:16
  • 1
    Try posting the full error. The console output you posted shouldn't be all of it. – Renzo Tissoni May 23 '19 at 16:28
  • I disabled OS_Acitivity Monitor. I removed it from the scheme but it doesn't show any more. –  May 23 '19 at 16:36
  • I updated my question with the full error –  May 23 '19 at 16:49
  • 2
    Disconnect the outlet connection named `videoImageView` and re-connect it again. When you rename something after a connection is made, storyboard may be corrupted and the shown connection cannot be relied on. – OOPer May 23 '19 at 16:55
  • You all were right! Thank you all for the help! It was the connection in my tablecell class that became corrupted due to me renaming them. I was assuming the viewController not the cell was the problem. By the way, disabling OS_Activity is a bad idea.. –  May 23 '19 at 18:21

0 Answers0