After a little digging, it looks like the TTPickerTextField class in which this code is located is an indirect subclass of UITextField .
Thus, it supports the UITextField delegate function, which does not comply with the TTPickerTextFieldDelegate protocol, where the textField:didAddCellAtIndex: method is textField:didAddCellAtIndex: .
I came to the conclusion that this code is just laziness. There is no reason why the UITextField delegation UITextField should have been copied, which makes this messy, error-prone code necessary.
My own approach was to leave the UITextField delegate property separate and add my own property in my specific subclass that handled specific delegate methods.
Just to clarify - the βsolutionβ that I mentioned in the question fixes the compiler error, but generates a warning that the method cannot be found, and it is assumed that it will return id. This is what the source code "solved", but only worked in GCC. No longer with LLVM 2.0.
Last edit, I promise:
My final solution to dealing with this laziness and getting rid of warnings and errors is an ugly hack:
[(id <TTPickerTextFieldDelegate>)self.delegate textField:self didAddCellAtIndex:(_cellViews.count - 1)];
Insert a UITextField delegate into an id that matches TTPickerTextFieldDelegate , and then call the method directly.
Please do not be lazy: (
Jasarien
source share