Has anybody had a positive experience with using IB for the interface along with a good memory management?
If I have an interface and implementation file for every view controller and view, and every ui element gets correctly initialized/released etc in code... do I have a chance to avoid memory leaks?
The app I'm developing has lots of diferent views and controllers and images that get loaded from the internet, and i just want to avoid as much as possible CGRect's and alike and place elements visually with IB, too much to ask?
It works fine. It can't stop leaks in your own code but loading/unloading views should be ok assuming you use the starting point code (init from nib, awake from nib, etc)
If you allow rotating your phone then you likely have to do some coding yourself for positioning subviews.
Thank you very much, it has been very useful to me, using loadNibNamed: I can load an an array of all the objects inside the xib and choose which one to load, really helpful!!
Good bye to having to program UI elements by hand!
The point now is, if a xib file has very many objects inside, will creating the array consume as much memory as initializing all?
Do i create separated xib to avoid wasting memory loading UI elements I don't need now?
When a nib is loaded every object inside it is created, whether they are shown or not. This takes up memory and also time. Typically you'll have one xib per main view/view controller and then load each nib as needed. Sometimes you'll have more than one view/view controller if it makes sense. What the file's owner object is and does controls how things are broken down.
loading a viewcontroller's view is straightforward, but how do you unload one? I know you can wait for a memory warning and let it happen automatically, but what if I want to programatically unload it ahead of time?
I'm loading the view with a nib, and releasing the view controller after pushing it on the navigation stack.
I do see the view controller deallocating when it is popped from the navigation stack, however the memory in object allocations doesn't change. Do I need to unload the objects in the nib somehow?
I haven't tried this but I think you can tell a view controller to unload its view as simply as
Code:
myViewController.view = nil;
One issue regarding viewcontrollers and nibs that's important is that Outlets need to be released in dealloc, and probably also in response to a memory warning.