Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6080289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:02:38+00:00 2026-05-23T11:02:38+00:00

When implementing the UITextFieldDelegate in my ViewController class, the following error is thrown when

  • 0

When implementing the UITextFieldDelegate in my ViewController class, the following error is thrown when entering the first character in the text field:

-[MyViewController respondsToSelector:]: message sent to deallocated instance...

So, I tried creating a separate class (inheriting only NSObject) and implementing UITextFieldDelegate. Guess what, it worked perfectly. However, that introduces some other problems as I have to do a lot of ugly cross-class-communication that I’d like to avoid. Here’s the relevant parts of my app delegate code:

@interface RMSAppDelegate : NSObject <UIApplicationDelegate,
                                      UITabBarControllerDelegate>

@property (nonatomic, retain) UIViewController* myViewController;

@end

@implementation MyAppDelegate

@synthesize myViewController;

- (BOOL)application:(UIApplication *)application
            didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    myViewController = [[MyViewController alloc]
                         initWithNibName:@"MyView" bundle:nil];
    [self.window setRootViewController:myViewController];
    [self.window makeKeyAndVisible];
    return YES;
}

@end

.. and here’s what is being displayed:

@interface MyViewController : UIViewController <UITextFieldDelegate>

@property (nonatomic, retain) IBOutlet UITextField* pinTextField;
- (void)viewDidLoad;

@end

@implementation MyViewController

@synthesize pinTextField;

- (void)viewDidLoad {
    // DOES NOT WORK (WHY?)
    //[pinTextField setDelegate:self];

    // WORKS, BUT I'D LIKE TO AVOID
    [pinTextField setDelegate:[[[MyTextFieldDelegate alloc] init] autorelease];

    [pinTextField becomeFirstResponder];
    [super viewDidLoad];
}

@end

And please, if you see any code (even off topic) that I could be doing better, leave a comment.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:02:39+00:00Added an answer on May 23, 2026 at 11:02 am

    Okay, I finally solved this on my own. I have not changed the code. My NIB (.xib) was the culprit!

    I thought that nested UIViewControllers was OK, and I still think they are in some cases (and maybe using another programmatic method). Anyway, I was initializing my class MyViewController with a NIB that in the Objects panel had a UIViewController as the first object.

    I solved this by having the UIView as the first object in the Objects panel, and setting the File’s Owner to be the UIViewController instead.

    Correct code, incorrect NIB. Thank you for your help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whilst implementing my first MVVM application in WPF, I've been wondering about the pros
In implementing M-V-VM in a project and following advice of Karl Shifflett about implementing
When implementing error-handling using the built-in validation-helpers on a strongly-typed view, you usually create
Implementing a Thread by providing a new class that extends Thread and overriding its
When implementing this method of NSCopying in a class to enable copy, what is
Implementing swing applications, often you realize class of components that should have a coherent
I'm having trouble setting a maximum length for the content of a text field.
while implementing hhtps, is there a way not to show the message Do you
When implementing a class with multiple properties (like in the toy example below), what
Implementing Equals() for reference types is harder than it seems. My current canonical implementation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.