Setting an object nil versus release+realloc

前端 未结 6 895
隐瞒了意图╮
隐瞒了意图╮ 2021-02-15 01:34

This is not a garbage collected environment

I have a class instance variable which at some point in my runtime, I need to re-initialize with a different data set than it

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-15 02:19

    One way to realize the difference might be this: Setting a reference to an object to nil does nothing to the object, it only does something to the reference.

    "Releasing the object" is not "nothing", so it doesn't do that. :) In a garbage-collected language it might do that as a side-effect of dropping the reference, but in Objective C it doesn't work that way.

提交回复
热议问题