Concise code · using a macro in a return statement


So, I bet this will sound familiar: for filling a table view you need to return either

  • The number of items in the datasource to indicate the required number of rows, or
  • 1 — in case there are no items and we need to show a cell stating that there is no content.

Solution 1 · Verbose

if ([self.catalogue.products count]) {  
    return [self.catalogue.products count];
} else {
    return 1;

Creating an if-else statement creates a lot of wasted space around the

Read More