I've got an array of NSNumber objects created thusly:
myArray = [[NSMutableArray alloc] initWithObjects:[NSNumber numberWithDouble:0.0],
[NSNumber numberWithDouble:0.0],
[NSNumber numberWithDouble:0.0],
[NSNumber numberWithDouble:0.0],
[NSNumber numberWithDouble:0.0], nil];
(Though just occurred to me that I could have done
myArray = [NSMutableArray arrayWithObjects: object1, etc..., nil];
and skipped the alloc entirely. Which would be better?)
Anyway, it's tangential to my question:
Over the life of the app, the values get changed. At a certain point, I want to reset them all to zero. Here's how I'm doing it now:
for (NSNumber *number in myArray) {
number = [NSNumber numberWithDouble:0.0];
}
But the Static Analyzer throws a warning because it thinks 'number' is an unused variable (which it technically is - set and then never used again). Is there a better way to zero out all the elements of the array? Perhaps replace the array with a new one? What would be fastest and avoid the static analysis warning?