Multiple views and source list in a Core Data app
Posted
by Ellie P.
on Stack Overflow
See other posts from Stack Overflow
or by Ellie P.
Published on 2009-08-01T06:41:02Z
Indexed on
2010/04/08
11:33 UTC
Read the original article
Hit count: 386
I'm working on my first major Cocoa app for an undergraduate research project.
The application is document-based and uses Core Data. One of the entities is an abstract entity, Page. Page
is parent of several types of pages: ie PageWithHeaderAndFooter, PageWithTwoColumns, BasicPage
etc. Page
has attributes, such as title and author, that all pages have in common. Each specific type of page has a certain number of layout blocks (PageWithHeaderAndFooter
has three: header, footer, body. BasicPage
has one: body. etc.) Additionally, all Page
subclasses define layout-specific implementations of certain methods.
The other relevant entity is Style
, which defines the visual look of a Page
. (Think of Page
s as HTML and Style
as CSS.)
I would like my app to have an iTunes/Mail-like source list with sections. (One section would be Pages, the other would be Styles.) I have a pretty good idea how to do the sectioned source list (this was a great help).
However, after hours of headbanging and fruitless googling, here's what I can't figure out:
Pages and Styles listed in the source list, and when you select one of them, all of the relevant fields for that object appear at the right (mostly NSTextViews, pop up menus, etc).
I laid that out and did all of the bindings in Interface Builder.
The problem is, if my source list contains different types of pages, how do I get a different view to display at the right depending on the type of page selected? For example, if a BasicPage
is selected, I want just what you see above: the general page stuff and one NSTextView that corresponds to the one field body
of BasicPage
. But if I select a PageWithHeaderAndFooter
, I want to display the general page stuff plus three NSTextViews (one for header, body, and footer.) If I have a Style
selected, I want to display various pop up menus, color wells, etc.
For the pages at least, we're only talking about one or more NSTextViews, each of which corresponds to a String attribute of the respective entity.
How would you do this?
Thank you for your help!
© Stack Overflow or respective owner