Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
zpasternack
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
3 ms
·
1.
▲
by
zpasternack
15y ago
> “Typing self.foo releases and nils the variables.” Yes, if it’s a retain or copy property. > “Just typing foo = nil is a memory leak.” Yes, if you had retained the object, but not if it were a weak reference. Admittedly, this is
2.
▲
by
zpasternack
15y ago
> 2. When you type "alloc" there is an implied retain. It's not quite that simple. The official rule from Apple's Memory Management Programming Guide most succinctly states "You take ownership of an object if you create it using a meth
3.
▲
by
zpasternack
15y ago
The same thing applies to "copy" properties. If you do "self.foo = bar;" when foo is a copy property, you have taken ownership of that object, and need to release it later (hopefully by doing "self.foo = nil;".