Can I just release the top object (iPhone)?
Posted
by yar
on Stack Overflow
See other posts from Stack Overflow
or by yar
Published on 2010-05-12T20:15:50Z
Indexed on
2010/05/12
20:34 UTC
Read the original article
Hit count: 179
objective-c
|memory-management
If I release the object that's holding a reference to the variable that I need to release, is that sufficient? Or must I release at every level of the containment hierarchy? I fear that my logic comes from working with a garbage collector for too long.
For instance, I assigned to this property of a UIPickerView instance by hand instead of using IB
@property(nonatomic, assign) id<UIPickerViewDelegate> delegate
Since it's an assign property, I can't just release the reference after I assign it. When I finally release my UIPickerView instance, do I need to do this:
[singlePicker.delegate release];
[singlePicker release];
or is the second line sufficient?
Also: Are these assign properties the norm, or is that mostly for Interface Builder? I thought that retain properties were the normal thing to expect.
© Stack Overflow or respective owner