如果是一道選擇題,那么有可能的選擇是:
A. 所有對(duì)象的dealloc方法會(huì)在主線程調(diào)用?
B. 一個(gè)對(duì)象的dealloc方法會(huì)在分配該對(duì)象的線程被調(diào)用?
C. 一個(gè)對(duì)象的dealloc方法會(huì)在該對(duì)象的引用計(jì)數(shù)變?yōu)?的線程被調(diào)用
說出你的答案!!!
一小段代碼便可以試出答案(thx to@CarinaT):
在@Matt Galloway的《Effective Objective-C 2.0》中(page164)對(duì)這個(gè)問題有描述:
Also, the dealloc method is called on the thread in which the final release that caused the retain count to zero occurred.