Я пытаюсь вытолкнуть информацию из выбранной ячейки ученика UITableviewCell
в контроллер вида с помощью UITextField
для каждой части информации (имя, фамилия и т. Д.), Чтобы она могла быть изменено, но я не могу найти, как выталкивать эту информацию из словаря в каждое текстовое поле. Я пробовал переназначить его без везения.Нажатие информации из словаря в UITextField (Swift)
Вот мой пример моего словаря быстрого файла
class ClassRosterModel {
//Student Dictionary for Student infomation
var studentsRoster = [Dictionary<String, String>]()
init() {
studentsRoster.append(["firstName": "Alex" , "lastName" : "Kaz", "major" : "SE", "email" : "[email protected]", "currentTerm" : "Spring", "numberOfCredits" : "\(randomCredits[0])", "password" : "000000"])
}
А вот часть моего класса, который имеет все ячейки перед выбором с Segue
class ClassRosterTableViewController: UITableViewController {
//declaring studentsList dictionary
var studentsList = [Dictionary<String, String>]()
var selectedRowIndex = 0
//Assignment of studentsList and myStudentRoster
let myStudentRoster = ClassRosterModel()
studentsList = myStudentRoster.studentsRoster
//declaring cell with identifier from studentCell.
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("studentCell", forIndexPath: indexPath)
// Configuring the cell with student information
cell.textLabel?.text = "\(studentsList[indexPath.row]["lastName"]!), \(studentsList[indexPath.row]["firstName"]!) - \(studentsList[indexPath.row]["email"]!)"
cell.detailTextLabel?.text = "\(studentsList[indexPath.row]["currentTerm"]!) - \(studentsList[indexPath.row]["numberOfCredits"]!) credits"
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let dvc = segue.destinationViewController as! StudentInfoViewController
let selectedStudent = studentsList[selectedRowIndex]
dvc.studentRecord = selectedStudent
}
И I просто сделал текстовое поле для имени на странице для студентов.
class StudentInfoViewController: UIViewController {
@IBOutlet weak var FirstNameTextField: UITextField!
var studentRecord = Dictionary<String, String>()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}