Beginning Table Views · Control Events | Ray Wenderlich


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5995-beginning-table-views/lessons/31

Hi @bdmoakley! To the end of the video the app constantly crashes if I pressing Cancel button. I found that this happening because Cancel button doesn’t properly connected to the @IBAction func cancel.

I haven’t noticed when connection between view and controller was broken, but maybe there is the way to check this kind of problems before runtime?

Hi @bdmoakley,

When I try to connect the Did End On Exit event to my done method, it doesn’t seem to behave in the same way that it did in your example. Dragging the connector onto the done method won’t highlight the method, but will instead only offer to insert an IBAction. Am I missing a step?

Thanks,
Will

Actually, scratch that I just answered my own question. Looks like when I connected the cancel and done IBActions, I had accidentally set the sender to UIBarButtonItem rather than Any, so it wasn’t accepting the appropriate inputs. Once I set the sender back to Any, it worked as demonstrated. Oops. :slight_smile:

Hi Berktv -

Generally this isn’t much of a problem. You could manually check or you can do UI tests to make sure there are no problems between builds. Often times, it’s a rare occurence and when it does happen, you’ll be immediately notified of it do to the app crashing.

1 Like

I’m glad to hear that you found the solution. Honestly, I find that these issues are great teachers. Once you run into a similar problem, you’ll know where to start investigating. Cheers!

Hi!

I tried to test the “did end on exit” event.
I typed and pressed the return key, but nothing happened.
I expected the same thing with the add button should happen.
What did I wrong?

It’s really hard to diagnose without additional information. Feel free to email your project to me at brian@razeware.com and I’ll take a look. Thanks so much!

Why not use ‘Editing Changed’ event to check if textfield is empty? Doesn’t it catch all cases like you implemented in shouldChangeCharactersIn handler?

In which scenario will the bellow guard return false?

guard let oldText = textField.text,
let stringRange = Range(range, in: oldText) else {
return false
}

You’ll have to play around. The text property is an optional one so we have to take account for it.

You just need to delete textFieldShouldReturn function in extension of UITextFieldDelegate and “did end on exit” event will trigger. Can somebody explain why this is working?

The same @bdmoakley :neutral_face:

@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]