http://www.otierney.net/objective-c.html#memorymanagement
Hello to all, and thank you upfront for reading. I just CANNOT grasp how retain/release counts work. The link above provides you with a simple AddressCard object and does some retaining and releasing.
I would REALLY like for someone to just walk through line by line with me, noting the retainCount of each variable along the way). For example:
After line 1, first has a retain value of 1.
After line 2, last has a retain value of 1
...
Here's what I really just don't understand:
1. WHY would i retain the f variable inside of setFirst? Correct me if i'm wrong, but that would increase the retainCount of f to 1. But then we never release f!!!
2. WHY would i do [first release]? It seems to me that the retainCount PRIOR to this call = 1; calling release would make it 0, and would deallocate it. Since it's been deallocated, line #3 (first = f) would become impossible.
Please help????
Hello to all, and thank you upfront for reading. I just CANNOT grasp how retain/release counts work. The link above provides you with a simple AddressCard object and does some retaining and releasing.
I would REALLY like for someone to just walk through line by line with me, noting the retainCount of each variable along the way). For example:
After line 1, first has a retain value of 1.
After line 2, last has a retain value of 1
...
Here's what I really just don't understand:
1. WHY would i retain the f variable inside of setFirst? Correct me if i'm wrong, but that would increase the retainCount of f to 1. But then we never release f!!!
2. WHY would i do [first release]? It seems to me that the retainCount PRIOR to this call = 1; calling release would make it 0, and would deallocate it. Since it's been deallocated, line #3 (first = f) would become impossible.
Please help????