NSArray guarantees
If there is a chance the NSArray is empty, is it better to check it and set it to nil if it is empty when it is assigned, or rather do a check when it is used?
eg.
NSArray *myArray;
if ([anotherArray count] > 0) <-- Check when assigned
myArray = [anotherArray copy];
else
myArray = nil;
something = [myArray objectAtIndex:x];
or
NSArray *myArray;
myArray = [anotherArray copy];
if ([myArray count] > 0) <-- Check when used
something = [myArray objectAtIndex:x];
What's better?
+2
a source to share