0
我發現了「線程1:。EXC_BAD_ACCESS(代碼= 2,地址= 0x16fc0bfefe8)錯誤我已經設置了iOS應用在登錄後訪問表視圖控制器它應該顯示圖像I被以下這。教程http://shrikar.com/uitableview-and-uitableviewcell-customization-in-swift/,但沒有運氣這是我data.swift文件,其中的誤差來自來源:你能幫助解決data.entry.init問題嗎?
import Foundation
class Data {
class Entry: Data {
let filename : String
init(fname : String) {
self.filename = fname
}
}
let products = [
Entry(fname: "placeholder1"), // <- Thread 1 error code shows in this line
Entry(fname: "placeholder2"),
Entry(fname: "placeholder3")
]
}
HomeTableViewController.swift
import UIKit
class HomeTableViewController: UITableViewController {
let data = Data()
override func viewDidLoad() {
super.viewDidLoad()
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.products.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! HomeTableViewCell
let entry = data.products[indexPath.row]
let image = UIImage(named: entry.filename)
cell.bkImageView.image = image
return cell
}
HomeTableViewCell.swift
import UIKit
class HomeTableViewCell: UITableViewCell {
@IBOutlet weak var bkImageView: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
虛心尋求一些幫助。提前致謝。