Difference between release and release then set to nil

前端 未结 5 1806
粉色の甜心
粉色の甜心 2020-12-29 17:14

What is the difference between two snippets?

[myObj release];

and

[myObj release];
myObj = nil;
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-29 17:44

    Not much. The second form just prevents you from accidentally trying to reuse the memory as if it was still an object. (As if it was the same object, to be precise. The memory address is likely to be reused for a new object shortly thereafter.)

提交回复
热议问题