0
添加對象我定義了三類:斯威夫特和境界:讓線程1:信號SIGABRT當列表
CoffeeBrand:
dynamic var brandName = ""
let brands = List<Coffee>()
咖啡:
dynamic var name = ""
let cupAmount = List<CoffeeCup>()
的CoffeeCup:
dynamic var cup = 0
dynamic var caffeine = 0
並且想試試它,所以我添加一個品牌星巴克試試怎麼會像在表中看到
class CoffeeListsTableViewController: UITableViewController {
// MARK: Properties
var brands: Results<CoffeeBrand>!
override func viewDidLoad() {
super.viewDidLoad()
let Starbucks = CoffeeBrand(value: ["Starbucks",["Iced Latte", [200,150],[500,150]]])
try! realm.write() {
realm.add(Starbucks)
}
}
}
但我得到的是「主題1:信號SIGABRT」,我查,我想這應該沒有線程1(這是我谷歌合作並試圖找到什麼是從別人的錯誤questiones)
隨着該表中的數據源:
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return brands.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
//let cellIdentifier = "CoffeeBrandTableViewCell"
let cell = tableView.dequeueReusableCell(withIdentifier: "CoffeeBrandTableViewCell", for: indexPath) as! CoffeeBrandTableViewCell
// in my cell, only a label of brandName
let brandList = brands[indexPath.row]
cell.brandName.text = brandList.brandName
return cell
}
不,這不是問題,我以前試過,它會得到「線程1:EXC_BAD_INSTRUCTION」 – whatever123