Better way to check for null to avoid crashes

Let’s consider this snippet of code:

Using respondsToSelector:

Obviously you can add additional checks, to see the kind of class, check the length and so on.

Leave a Reply

Your email address will not be published.