if i have a NSMutableArray with a retain count of 1 and this array has multiple class A objects that have variables with retain count greater then 1, what happens to this variables if i release the array? are they forced to release every retained count and release space or wil they stil occupy memory ?
Share
Releasing the array has the same effect as removing all the items from the array. That is, the array no longer claims ownership of them. If anyone else has retained the objects, they’ll continue to exist. If not, they’ll be deallocated.
This is just the normal set of memory rules in effect. If you retain an object, you must release it. Conversely, other bits of code (like an array) are allowed to retain and release that object when they want to own it, too, but if everyone follows the rules, nobody gets surprised.