Hi fellow programmers! I have a problem that I need help with. I built a table using a special style cell.
This cell just has Labeland UISwitch. The name is displayed on the label, and a switch indicates whether they are an administrator or not. It works great. My problem is how and where can I put the code in response when the switch changes.
So, if I click on the switch to change it from place to place, where can I print the personβs name? If I can get the name to print, I can make the php / sql code myself. Thanks, and here is a snippet of my code.
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier) as UITableViewCell
let admin = self.admin[indexPath.row]
let text1a = admin.FirstName
let text1aa = " "
let text1b = admin.LastName
let text1 = text1a + text1aa + text1b
(cell.contentView.viewWithTag(1) as UILabel).text = text1
if admin.admin == "yes" {
(cell.contentView.viewWithTag(2) as UISwitch).setOn(true, animated:true)
} else if admin.admin == "no" {
(cell.contentView.viewWithTag(2) as UISwitch).setOn(false, animated:true)
}
return cell
}
source
share