[Error] This class is not key value coding-compliant for the key trendTableView.

 

스토리보드 때문에 생기는 문제였다.

 

현재 이전 코드를 조금 더 예뻐 보이게 바꾸는 중인데 ^__^ ,, SceneDelegate에서 앱을 실행 시 처음에 Storyboard와 연결해서 실행하드라. 

 

        if UserDefaultsHelper.shared.haveBeenBefore {
            // 처음이 아닐 때
            let sb = UIStoryboard(name: "Main", bundle: nil)
            
            guard let tabBarController = sb.instantiateViewController(withIdentifier: "mainTabBarController") as? UITabBarController else {
                fatalError("탭바 컨트롤러를 가져올 수 없습니다.")
            }
            
            let firstNav = UINavigationController(rootViewController: TrendViewController())
            firstNav.tabBarItem = UITabBarItem(title: "Today's Trend", image: UIImage(systemName: "sparkles.tv.fill"), selectedImage: UIImage(systemName: "sparkles.tv.fill"))
            
            guard let secondVC = sb.instantiateViewController(withIdentifier: RecommendationViewController.identifier) as? RecommendationViewController else { return }
            let secondNav = UINavigationController(rootViewController: secondVC)
            secondNav.tabBarItem = UITabBarItem(title: "Recommendation", image: UIImage(systemName: "magnifyingglass.circle.fill"), selectedImage: UIImage(systemName: "magnifyingglass.circle.fill"))
            
            guard let thirdVC = sb.instantiateViewController(withIdentifier: TheaterViewController.identifier) as? TheaterViewController else { return }
            let thirdNav = UINavigationController(rootViewController: thirdVC)
            
            let fourthVC = ProfileViewController()
            let fourthNav = UINavigationController(rootViewController: fourthVC)
            fourthNav.tabBarItem = UITabBarItem(title: "Profile", image: UIImage(systemName: "person.crop.circle.fill"), selectedImage: UIImage(systemName: "person.crop.circle.fill"))
            
            tabBarController.viewControllers = [firstNav, secondNav, thirdNav, fourthNav]
            
            window?.rootViewController = tabBarController
            window?.makeKeyAndVisible()
        }

 

해당하는 스토리보드를 지우고 스토리보드와 이어지는 코드를 바꿔서 해결했다!

 

이전에 스토리보드 베이스의 코드를 코드베이스로 리팩토링했었기 땜에 ,, ^__^

일부 코드는 스토리보드고 또 일부는 코드베이스로 되어 있다. 

 

이번에 본 오류는 난생 첨 보는 거라 엥? 했는데 구글링하니 생각보다 빨리 해결했다

 

무조건 스토리보드와 연결하는 코드를 썼을 때, 스토리보드에서 등록했던 뷰컨트롤러와 제대로 연결되지 않아 생기는 오류 같으니 스토리보드와 해당 스토리보드와 연결된 코드를 보면 쉽게 해결할 수 있을 것이다.