Objective-C pointers?

前端 未结 7 1664
无人及你
无人及你 2020-12-29 10:49

I am new to coding and trying to get up to speed with Objective-C. Came across some code I did not understand. I was hoping someone could clarify it for me. In the case belo

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 11:29

    Because you haven't released it. You're releasing references here, not freeing pointers. It's not quite the same thing. When you do [foo release] the second time, you're releasing the foo reference that you created when you assigned foo2 to foo.

    To release the foo2 reference, you need to actually call release on that reference, not a copy of the reference.

提交回复
热议问题