I’m new with iOS development, but I’m familiar with the memory management basics in Obj-C. However, Apple’s docs about custom UIViewControllers confused me a bit.
So, I have a PagingController that stores an array of EntryViewController objects. (They’re all UIViewControllers.) These objects are loaded dynamically and, of course, released when appropriate. The view in PagingController is created in -loadView and stored in self.view, just as the documentation said.
Whenever I load an EntryViewController (as ctrl), I call [self.view addSubview:ctrl.view];. I also need to call ctrl.parent = self; since the target OS is 3.0 and I don’t want to modify a private variable (_parentViewController). (parent is defined as @property(assign) PagingController *parent;)
Here are my questions:
- Do I have to release
self.viewmyself, or is UIViewController taking care of that? - Do I have to retain
parent(the property inEntryViewController)? I assume it’s pointless, since all the child view controllers are being released when the parent is unloaded. - Do I have to call
[self.view removeFromSuperview]in the-deallocmethod ofEntryViewController? The docs said, I have to manage all of the subviews, so I’m not sure if this gets called automatically.
Or am I just confused about how to create a custom view controller in the first place?
1 Answer