is there any common pattern to create singleton objects for each thread?
When I send a sharedInstance message to the singleton class, I expect an instance that is shared only for the currentThread.
Thanks
EDIT: I found this post very useful http://ddeville.me/2011/02/creating-shared-instances-of-non-thread-safe-classes/
A singleton and one object per thread requirement is an contradiction.
You probably want a
thread localobject. That is one object specific for each thread.Thread local objects can be implemented by using
[NSThread threadDictionary].There you could store such an object as
NSValuewhich can hold even a pointer.