Mon 01/08/16

1) Disadvantage in using delegate of UITextField due to changing values in Cell's text fields.  

    If you have UITableView with UITextField in it's cells, you need to update it. There are some ways, and one of them to use UITextFieldDelegate like in example:


func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
if string == " "
{
return false
}

let indexPathForCellWhereTextFieldIs = self.tableView.indexPathForCell(textField.superview?.superview as! UITableViewCell)
if indexPathForCellWhereTextFieldIs != nil
{
textFieldValues[(indexPathForCellWhereTextFieldIs?.section)!] = (textField.text! as NSString).stringByReplacingCharactersInRange(range, withString: string) as NSString as String
}
return true
}


So you have to check if indexPathForCellWhereTextFieldIs is'n nil.

Комментарии

Популярные сообщения из этого блога

Xcode Source Extensions Setup

Find out, what controller is on the top.

Xcode Swift Speed Up compilation