I have an array of NSNumber objects created this way:
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];
(Although it just occurred to me that I could do
myArray = [NSMutableArray arrayWithObjects: object1, etc..., nil];
and completely missed the selection. What would be better?)
Anyway, this concerns my question:
Over the life of the application, the values change. At some point, I want all reset to be zero. Here's how I do it now:
for (NSNumber *number in myArray) {
number = [NSNumber numberWithDouble:0.0];
}
But the static analyzer generates a warning, because it considers that the "number" is an unused variable (which it is technically set, and then never used again). Is there a better way to reset all array elements? Perhaps replace the array with a new one? What would be the fastest and avoid the static analysis warning?