I have done a bit of iOS development lately. While trying to get myself familiarized with the new platform, I came across this book titled “Programming iOS 4”. I skimmed through some sections and found this paragraph:
You should not use a view controller in any other way. It is not, for example, appropriate to use a view controller to manage a view that occupies only a part of the window, or is a subview of anything except the window as a whole, except as a side effect of the fact that this is a contained view controller. This, I take it, is what Apple’s documentation means when it says:
You should not use multiple custom view controllers to manage different portions of the same view hierarchy. Similarly, you should not use a single custom view controller object to manage multiple screens worth of content…. If you want to divide a view hierarchy into multiple subareas and manage each one separately, use generic controller objects(custom objects descending from NSObject) instead of view controller objects to manage each subarea.
I had to read the firsts paragraphs three times and still couldn’t be sure that I understood what it’s trying to say. It makes sense to suggest that one shall not use a view controller for a sub-element of a view (think of buttons and labels etc. which are technically subclasses of UIView). Not using a view controller for a subview of anything except the main window does not seem to align with the idea of UINavigationController or UITabBarController. The last “except” clause in the paragraph could be referring to these “side effects”, except it made the sentence more confusing (damn, except is infectious)! Anyway, I think the Apple documentation paragraph explained the idea more clearly without the use of double-except clauses. I’m thankful that the author put the documentation text in there for people like me
I believe that often many concepts are in fact quite simple. It just takes great skill and knowledge to present them in a clear and concise way. I have no opinion on the book as a whole since I have not read it completely. Who knows, I may find it very useful.
Did you find out what it means?
I have the same problem and I dont know what to do. Did you find a solution?
Thanks in advance.
Victor, what problem are you referring to?