The dreaded double-segue mistake

This turns out to be a surprisingly common mistake with table views and collection views:

  1. In the storyboard, you connect a segue from the cell prototype to another view controller.

  2. In code, you implement the delegate method didSelectRowAt or didSelectItemAt to call performSegue to trigger the segue.

The result of this mistake is that when the user taps the cell, the segue is triggered twice.

Continue reading

Using a value after it has been set by asynchronous code

By now you may have read this post explaining what “asynchronous” means. If you haven’t, please read it first!

So, if you understand what “asynchronous” means, then you won’t make the biggest mistake that people tend to make with asynchronous code, namely: outside asynchronous code, trying to use a value that depends on asynchronous code.

Continue reading