Note that there are some explanatory texts on larger screens.

plurals
  1. POUITextFieldDelegate Causes Exception
    text
    copied!<p>Simple Case. I want to create a UIViewController displaying and reacting to the input of a simple UITextField. </p> <ol> <li>I created a UIViewController including the <strong>xib</strong> file. </li> <li>In Interface Builder I added a <strong>View</strong> and a containing <strong>UITextField</strong>. </li> <li>The <strong>File's Owner</strong> is set to the according class name that contains the logic "CardViewController". </li> <li>The File Owner points to the View as view. </li> <li>The <strong>text field</strong> uses the <strong>File's Owner</strong> as <strong>delegate</strong>.</li> </ol> <p>It looks like this...</p> <p><img src="https://i.stack.imgur.com/WCMvs.png" alt="enter image description here"></p> <p>The view is being displayed correctly, but as soon as I tap the textfield the application crashes with an exception "EXC_BAD_ACCESS...."</p> <p>My guess is that there's something wrong with the assignement of the delegate, but I have problems finding the issue. Any idea? What did I miss?</p> <hr> <p>Further Findings. When I instantiate this viewcontroller directly <strong>in the AppDelegate the delegation of the UITextField actually works!</strong>!</p> <p>But what I actually plan to do to create an instance of a "BoardViewController" class first which then creates "CardViewController" objects. Having this kind nesting causes the delegation to fail.</p> <p>As a reference. In my App Delegate:</p> <pre><code>BoardViewController *bvc = [[BoardViewController alloc] init]; [self.window setRootViewController:bvc]; </code></pre> <p>in the Board Class I have a "add" button that triggers the creation of the CardViewControllers</p> <pre><code>-(void) addCard:(id)touchEvent{ NSLog(@"&lt;Board&gt; Add"); CardViewController *cvc = [[CardViewController alloc]init]; [self.view addSubview:cvc.view]; } </code></pre> <p>and then the CardViewController looks as mentioned at first with the delegation being set in the xib.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload