allAssets = nil?


#1

What’s the point of setting allAssets to nil?


#2

If you are using ARC setting an object pointer to nil indicates that you no longer wish to use the corresponding object and it should be released when it has no other owners left.

If you are operating under MRC (manual reference counting), setting an object pointer to nil will disconnect you from the corresponding object and may also result in its retain count being decremented by one when the object pointer is a property.


#3

But wouldn’t ARC automatically release the object at the end of main() anyway?


#4

That’s true, but if you have a long running program you need to release the resources that you no longer need. (In the computing world, it is not uncommon to find programs that run continuously more than a year!)


#5

Cool, thanks ibex!