thread safe nsdictionary
问题 I have an nsdictionary that gets read from A LOT and at some points concurrently written to A LOT. To help make it thread safe when iterating it, I copy it, iterate the copy, and add to the original. Sometimes, another thread is copying it while it is being added to. Is there a better way to make it thread safe? 回答1: If you have changes you want to make to an NSMutableDictionary and need the operations to be done in a thread-safe manner, the simplest way is to wrap all accesses on that object