Quantcast
Viewing latest article 2
Browse Latest Browse All 4

Coding Tip: Replace Complicated Conditions With Boolean Variables

Consider the following if statement:

if(dragOperation != NSDragOperationCopy && NSPointInRect(currentMouseLocation, self.bounds)){
    //do something
}

Even though you may have worked out what the condition represents, it probably took you a little longer than it should. It's complicated, making it time consuming to read, and prone to bugs upon modification. Thankfully, there is an easy remedy:


Viewing latest article 2
Browse Latest Browse All 4

Trending Articles