0

How would I suppress the warning in this code snippet?

for (NSDictionary *record in self.records) {
    [deletedRows addObject:[NSIndexPath indexPathForRow:row inSection:RecordSection]];
    row++;
}
Calvin Cheng
  • 34,202
  • 32
  • 113
  • 164
  • #pragma GCC diagnostic ignored "-Wwarning-flag" suppresses warnings http://stackoverflow.com/questions/194666/is-there-a-way-to-suppress-warnings-in-xcode – Rachel Gallen Jul 02 '14 at 07:35
  • 1
    You can use __unused like __unused NSDictionary *record – Ryan Jul 02 '14 at 07:35

1 Answers1

2

Don't use fast enumeration at all:

for (NSUInteger row = 0; row < [self.records count]; row++) {
    [deletedRows addObject:[NSIndexPath indexPathForRow:row inSection:RecordSection]];
}

This is:

  1. Faster, as you are not accessing the array, just generating a sequence of numbers.
  2. Cleaner, as there are no annoying compiler directives.
  3. Correct, as you don't declare a variable you don't use.
trojanfoe
  • 118,129
  • 19
  • 204
  • 237