前提
お天気APIアプリを作成しており、ビルド時にエラーが吐かれます。
これはStoryboardの接続がおかしいときに出るエラーと認識しているので、
全て接続し直してみたのがエラーは解消されず…
検索しても**「接続しなおせばなおる」**という記事ばかりで解決できておりません。
接続の仕方以外に、何か問題があればご教授いただければと存じます。
宜しくお願い致します。
発生している問題・エラーメッセージ
調べたところ、どちらのエラーも接続がダメな時に出るのはわかりました。
this class is not key value coding-compliant for the key
libc++abi.dylib: terminating with uncaught exception of type NSException
該当のソースコード
TableViewと接続しているクラス
ViewController
1import UIKit 2import Alamofire 3import Foundation 4import RealmSwift 5 6protocol ViewDelegate: class { 7 func updateAPI(weatherLists : [DbTable]) 8} 9 10class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, ViewDelegate { 11 12 var weatherApiModel = WeatherApiModel() 13 var weatherListsResult: [DbTable]? 14 @IBOutlet weak var table:UITableView! 15 16 override func viewDidLoad() { 17 super.viewDidLoad() 18 19 receiveEvent() 20 21 } 22 23 func receiveEvent() { 24 weatherApiModel.delegate = self 25 weatherApiModel.weatherApi() 26 } 27 28 func updateAPI(weatherLists : [DbTable]) { 29 weatherListsResult = weatherLists 30 self.table.reloadData() 31 } 32 33 //Table Viewセル数指定 34 func tableView(_ table: UITableView, 35 numberOfRowsInSection section: Int) -> Int { 36 guard let weatherListCount = weatherListsResult?.count else { return 0 } 37 return weatherListCount 38 } 39 40 //各セル要素設定 41 func tableView(_ table: UITableView, 42 cellForRowAt indexPath: IndexPath) -> UITableViewCell { 43 44 guard let cell = table.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath) as? TableViewCell else {fatalError("cell error")} 45 guard let date = weatherListsResult?[indexPath.row].date, 46 let telop = weatherListsResult?[indexPath.row].telop else {fatalError("error")} 47 48 cell.dateLabel.text = date 49 cell.telopLabel.text = telop 50 51 guard let iconUrl = weatherListsResult?[indexPath.row].iconUrl else {fatalError("error")} 52 guard let url = URL(string: iconUrl) else {fatalError("error")} 53 if let iconData = try?Data(contentsOf: url) { 54 cell.iconImageView?.image = UIImage(data: iconData) 55 } 56 57 return cell 58 } 59} 60
Labelとimageを接続しているクラス
TableViewCell
1 2import UIKit 3 4class TableViewCell: UITableViewCell { 5 6 @IBOutlet weak var dateLabel: UILabel! 7 @IBOutlet weak var iconImageView: UIImageView! 8 @IBOutlet weak var telopLabel: UILabel! 9 10 override func awakeFromNib() { 11 super.awakeFromNib() 12 // Initialization code 13 } 14 15 override func setSelected(_ selected: Bool, animated: Bool) { 16 super.setSelected(selected, animated: animated) 17 18 // Configure the view for the selected state 19 } 20 21} 22
補足情報
MacOS:Catalina ver10.15.5
Xcode11.6
回答1件
あなたの回答
tips
プレビュー