Wednesday, 4 July 2012

Top Tip

How many times have you had to do something like this

int count = [NSArray count]
count--;

to allow for the 0 index?

i.e if it has a count of 3 it actually contains index 0,1,2

try using this instead

#define minus(x)(x - 1)

[array objectAtIndex:minus(count)];

saves times and lines.

No comments:

Post a Comment