1
오류가하자 selectedStudent 라인에 발생하는되는 곳입니다, 내가 studentsSorted 및 studentArray를 선언 할 경우 다음 스레드 1 :. EXC_BAD_INSTRUCTION (코드 = EXC_I386_INVOP 오류 .. 정말 확실하지 왜
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
if(segue.identifier == "Student_segue") {
if let indexPath = self.tableView.indexPathForSelectedRow {
let selectedStudent = studentsSorted[indexPath.row]
let destination = segue.destinationViewController as! StudentInfoTableViewController
destination.selectedStudent = selectedStudent
}
}
}
가
typealias studentInfo = Dictionary<String, AnyObject>
typealias studentArray = [studentInfo]
let students = StudentRosterModel()
var studentsSorted:studentArray = studentArray()
var selectedRow:Int = 0
func updateStudentInfo(updatedStudent: Dictionary<String, AnyObject>) {
// replaced the selected row with the updated key/value dictionary
studentsSorted [selectedRow ] = updatedStudent
// sort the revised student list
studentsSorted.sortInPlace{ ($0["last_name"] as? String) < ($1["last_name"] as? String)}
// reload() tableView to show refreshed view
tableView.reloadData()
}
내가 selectedStudent를 선언 곳이다, 여기
class StudentInfoTableViewController: UITableViewController, UITextFieldDelegate {
var selectedStudent: Dictionary<String, AnyObject> = Dictionary<String, AnyObject>()
var delegate: studentUpdate?
정말 혼란, 내가 좋겠 누군가가 나를 도울 수 있다면 고마워.
그래, studentsSorted 배열에 아무것도 없다는 것을 알았지 만 그 이유를 알 수 없습니다. – Grady
'studentsSorted'에 데이터를 삽입하는 함수에 대한 정보는 없습니다. 난 그냥 교체 및 정렬'updateStudentInfo'를 찾을 수 있습니다. – NEWBIE
'studentsSorted'에 데이터를 삽입하는 방법을 보여줄 수 있습니까? – NEWBIE