So I'm trying to separate out my delegate into a separate class instead of housing it in my cell class. Here's how I declare and initialize the delegate:
class RegistrationTableViewController: BaseTableViewController, UITextFieldDelegate {
var textFieldDelegate: UITextFieldDelegate
//MARK: - Initialization
required init?(coder aDecoder: NSCoder) {
textFieldDelegate = RegistrationTextFieldDelegate()
super.init(coder: aDecoder)
}
Then I set it in my general cell setup method:
func setupBaseCellWithType(type: Constants.Registration.CellType) -> BaseCell {
var cell: BaseCell? = nil
if let newCell = tableView.dequeueReusableCellWithIdentifier(Constants.Registration.profileBaseRegistrationCell) as? BaseProfileCell {
newCell.cellType = type
newCell.setupCell()
newCell.setTextFieldDelegate(textFieldDelegate)
cell = newCell
}
return cell!
}
The problem is, it never hits any of the delegate methods. It was working great when I made the cells my delegate, any idea whats going wrong here?
Edit: setTextFieldDelegate
calls this method:
private func setTextFieldDelegates(delegate: UITextFieldDelegate) -> Void {
for textField in textFieldArray {
textField.delegate = delegate
}
}
That was how I set the delegate on all my textFields in the cell previously, so I know it's correctly setting them there, but something is going wrong in me trying to move it to another class.
Edit 2: I'm an idiot who's running on low sleep. I was only changing the BaseCell delegate, not my PhoneNumberCellDelegate... Feel free to call me an idiot if you'd like.