Objective-C: Why should one check for != nil

前端 未结 4 1162
遇见更好的自我
遇见更好的自我 2020-12-20 01:31

I often see code like this:

// Approach 1
if(data != nil){
    // Do this and that
}

When one could simply do the check like this:

4条回答
  •  情歌与酒
    2020-12-20 02:28

    It is all about coding preferences. Some might feel that the longer form is more clear as to intent, others that it is overly verbose.

提交回复
热议问题