Search code examples
iosuitextfielduitextfielddelegate

Why is textFieldwithPlaceHolderText undefined for one view controller that conforms to UITextFieldDelegate?


I have two UIViewController sublcasses, both of them conform to the UITextFieldDelegate protocol. IOW, I have these classes.

# MyVC1.h
@interface MyVC1 : UIViewController <UITextFieldDelegate>

# MyVC1.m
@interface MyVC1 () {
    // Private variable, so not a property
    UITextField *_myTextField;
}
@end

@implementation MyVC1

- (void)viewDidLoad
{
    _myTextField = [self textFieldwithPlaceHolderText:@"*Text"];
}
@end

SAME CODE for MyVC2 class, except of course the class name.

However, and this is the strange part, my code compiles for MyVC1, but NOT for MyVC2. For MyVC2, compiler says "No visible @interface for "MyVC2" declares the selector "textFieldwithPlaceHolderText". What am I missing for MyVC2? I've double- and triple-checked!


Solution

  • Ok, it's late, and I'm sleepy. MyVC1 defines the textFieldwithPlaceHolderText method, but NOT MyVC2. I cut/past the viewDidLoad section, but forgot to cut/paste the method. Sorry to waste your time.