|Subject:||Re: NSThread Comparisons|
|Date:||Fri, 4 Jan 2008 16:25:11 +0100|
Justin Kendrick wrote:
I'm writing a class which needs to determine the current thread and get an object tied to that thread. I'd like to use an NSDictionary keyed by an NSThread object, but NSThread instances not copyable (and I can't find any good documentation on how NSDictionary matches non-NSString keys anyway). Beyond that, I thought that I might use an NSValue created with valueWithUnretainedObject:, but that feels really hackish.
Your approach looks backwards to me. Each thread has a mutable dictionary where you can save thread specific data (cf. NSThread's - threadDictionary method). Why don't you save your objects there (with an appropriate key) and use +currentThread to determine the current thread?
|[Prev in Thread]||Current Thread||[Next in Thread]|