swift - TableViewController didSelectRowAt SIGABRT Error (no faulty connections) -
i have tableview gets data realm database. want select multiple rows , want give them checkmark , set "selected" attribute of exercises "true". if try code here sigabrt error. i've researched error , found out going happen when have wrong setted outlets in storyboard or when don't set reuse identifier right. checked it's okay. have idea error can come if storyboard configured right? (sorry bad english) here's code:
override func tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) { if fromtrainingplan == true && request2 != nil{ tableview.deselectrow(at: indexpath, animated: true) let excercises = request2![(indexpath nsindexpath).row] let cell: uebungentableviewcell = tableview.cellforrow(at: indexpath) as! uebungentableviewcell if excercises.selected == true{ excercises.selected = false //crash print("1") } else{ excercises.selected = true print("2") } if excercises.selected == true{ cell.accessorytype = .checkmark print("3") } else{ cell.accessorytype = .none print("4") } } }
i used breakpoints delimit error , found out exercise.selected = false statement causes error, have no idea why.. btw: first if else condition causes error, second doesn't crash program.
this exercises class:
class excercise: object { dynamic var trainingsplan: trainingplan? dynamic var selected = false dynamic var name = "" dynamic var excercisedescription = "" dynamic var musclegroup = "" dynamic var record = 0 dynamic var picture: nsdata? let sets = list<trainingset>()
}
request2 has datatype results[excercise]?.
Comments
Post a Comment