12-11-2009, 09:44 AM
|
#5 (permalink)
|
|
Registered Member
Join Date: Nov 2008
Posts: 34
|
Quote:
Originally Posted by BrianSlick
The +1 you saw was from addSubview. The parent view is retaining its subviews. You do not need to worry about that. If you later remove it from that view, or if it still exists when that view is deallocated, a release message will be automatically sent at that time.
Your responsibility is to balance your memory-related actions - alloc, copy, new, retain - with a release.
It is not your responsibility to guess how Apple's classes work. The implementation for addSubview could retain your slider one time, or it could retain it many times. You have no way of knowing. You have to trust that whatever Apple's classes DO, they will also UNDO appropriately. Same for arrays, dictionaries, etc. The act of adding an object to an array, just like adding your slider to a view, does not involve alloc, copy, or new (unless you do it wrong), so it should not be released.
|
@BrianSlick: Thanks for the explanation.
|
|
|