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
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.