Is dealloc guaranteed to be called on the same thread that created the object?

后端 未结 3 496
后悔当初
后悔当初 2020-12-16 04:14

Is dealloc guaranteed to be called on the same thread that created a NSObject instance? For example, if I call [[MyFluffyBunny alloc] init]

3条回答
  •  长情又很酷
    2020-12-16 04:45

    I'm unaware of a line in the documentation that says anything about this, but here are some points of logic:

    • If you can't find a guarantee somewhere, assume it doesn't exist. (It sounds like you're aware of this already, and are hoping beyond hope that somebody else can point you to something that gives you the answer you want)

    • That requirement cannot be possible because you can construct something on a thread, then end that thread, then have the last reference go out of scope somewhere else in some other thread. It wouldn't be possible at this point to dealloc on the old thread because it no longer exists.

提交回复
热议问题