In a project with garbage collection set to required: If I instantiate an object in Interface Builder and add it to the XIB/NIB, do I need to assign this object to some outlet to avoid it being garbage-collected, or is that taken care through some other means?
Share
I just built a small test project. With GC, the object created through Interface Builder gets collected soon afterwards. So the answer to the question is: yes.
I did a bit more testing:
With classical reference counting this does not happen. This is possibly what one would expect, but it is also probably a memory leak. Not sure here. (If not, and the NIB/XIB-contained objects get released when the file’s owner is release, e.g., then this would constitute a significant difference in behavior between GC and classical RC.)
With ARC enabled, I did not find a way to tell. There is probably some function I could put a breakpoint on and wait for the specific object fly by.
Edit:
I reviewed the documentation, and it states it quite clearly. Missed that the first time around:
From: Resource Programming Guide, Managing the Lifetimes of Objects from Nib Files