If the API does not say that it is thread safe, it is not. Even if the current implementation is thread safe, it may not be in the future. In other words, do not use AB from multiple threads.
As an aside, how about being based on CoreData, do you think it will be thread safe? CoreData uses a thread restriction model where only access to the context in one thread is safe, all objects from the context should be available in one thread.
This means that sharedAddressBook will not be thread safe if it supports NSManagedObjectContext for use. It would be safe if AB created a new context every time he needed to do something, and immediately deleted it, or created a context for the thread and always used the appropriate context (possibly keeping a link to it in threadDictionary), Any It would be safe for the case to store something like NSManagedObjects, since contexts will be permanently destroyed, which means that each ABRecord will have to store NSManagedObjectID so that it can recreate the object in the corresponding context whenever it is needed.
It is clear that all this is possible, perhaps this is what has been done, but this is hardly an obvious implementation.
Louis Gerbarg
source share