May 16, 2015
Brent Simmons: How Not to Crash #2: Mutation Exceptions:
"You get a collection from somewhere and enumerate it — and then you get an error about the collection being mutated as it was being enumerated. The app crashes.
"You can avoid this unhappy fate with one simple trick: don’t enumerate mutable collections."
…
"That’s perfectly legal code: because mutableOperations is an NSMutableArray, it’s also an NSArray. (I did it this way for years. I thought to myself, “Hey, I’m a grownup. I can handle it.” But what I didn’t realize was that grownup developers write code to make errors less likely.)"