Fix a crashing bug in iOS 5.x

Seems to be due to mutating a collection while enumerating it. I thought
we'd be OK there because we're only calling replaceObjectAtIndex:withObject:
but apparently not. Weirdly, it worked OK on iOS 6.