0

I gather that if I create an autoreleased object and I pass it to another thread to be worked on, this is bad if the first NSThread should happened to clean out its autorelease pool, or be killed. However if I want to avoid autoreleasing as a rule, what are some examples of where I cannot autorelease objects, particularly objects that I might want to share between NSThreads? It seems to me that most autoreleasing can be avoided.

1 Answers1

0

Just follow the memory management rules. Threads make no difference. A function only has to worry about what it does locally; it never has to worry about what any other function does. A function needs to retain an object if it needs to be assigned to an instance variable or something like that. When something is retained, it needs to be balanced with a release.

newacct
  • 119,665
  • 29
  • 163
  • 224