You want to use UIViewController instead and put a UITableView on that. That way you can move things around at your discretion. You will have to manually implement UITableViewDelegate and UITableViewDataSource though.
A UITableView is composed from cells (UITableViewCell objects). Apple's own documentation should help out. Plus, when you get to customizing and using cells this section will help.
I would agree with cirrostratus that in some cases you can use UIViewController + UITableView more effectively than UITableViewController. See this good post: cocoawithlove. Com/2009/03/… If the use-case is pretty straight-forward I'd stick with UITableViewController.
If you're using core data also look out for the very useful NSFetchedResultsController. – petert May 21 '10 at 8:47.
In the nib for my TableViewController, I see the TableView (with its example values of California cities) but I'm able to drop any other UI elements on it (for example an UILabel). I can add a UIWindow which gives me a separate window to add stuff onto but when I start my app all I see is the table view. What am I missing?
How do you mesh these elements together?
Why not have an Item have the following relationships: belongs_to :book belongs_to :furniture belongs_to :electronic You can then only actually set on of these, and can do a test of if item. Book #do things end for each item, if you care about whether it's a book, etc. You can even use validations to make sure it only ever belongs to one thing at a time.
So far, I would have Item Model. And I would add additional models for Categories other than Books, Furniture, and Electronics correct? – BriteLite Jun 25 '10 at 15:36 Sure, though I'm not exactly sure why you would need an Item model (are you just trying to show that Books, Furniture and Electronics are all Items?
Like a form of super class? ), but in general, that's how I handle a Model that might belong to one or more other models. – Jenny Jun 25 '10 at 16:37 Just from your description, I personally wouldn't have an item at all, and just worry about Book/Furniture/Electronics.
If you ever need to display everything in the database, then display @books, @furniture, etc. In a row? For example, I might have a Cat model and a Mouse model...but I wouldn't gain much from ALSO having an Animal model that both belong to unless I planned on doing something with the inheritance. If I ever want to show all animals, then I just show all cats, and all mice, you know?
– Jenny Jun 25 '10 at 16:40 Thank you for your response Jenny. Apeacox below responded with a need for Polymorphic relation which I think makes sense. I mean, from what I understand, since an ITEM, has one CATEGORY.
And the model CATEGORY consists of BOOK, or FURNITURE models(with appropriate database fields), it would make sense to have ITEM be a polymorphic, so that it can apply to BOOK, or FURNITURE. I mean in plain English, what I am trying to do is, find out how to make CATEGORY model consist of BOOK, and FURNITURE model, so that I can attach an ITEM to a category, so that in the view, I can render the rite templat – BriteLite Jun 25 '10 at 18:45.
I don't think you need the category model. You can just create the book, furniture and electronic models and one controller for each one. Edit No, there's no advantage.
I just said to create different models/controllers because what you're modeling, in my opinion, are different things. But if you think they'll have a lot in common, I'd suggest for you to use single table inheritance. This way you'd have a single table for every item and can have only one controller, but each item would have one model.
Is there an advantage to using multiple controllers, versus just relating the models using some form of relationships and just using one controller. I say that because the controller will have one purpose: to determine which category the item is and then render the appropriate template. – BriteLite Jun 25 '10 at 15:41.
The Item model could be declared as polymorphic (se here: guides.rails.info/association_basics.htm...) so you'll declare Item: class Item true end then the 3 models that act as category (I'll show one, the others are same): class Employee :category end # and so on... this way you can associate an Item to one of the 3 models (Book, Furniture and Electronics). Each instance of these models will have an 'items' atribute, like this: @book. Items # returns all the items associated to a @book object You can also use has_many association using a polymorphic model.
For the views, you can use Nested Form Objects (see here: http://guides.rails.info/form_helpers.html). Basically, in each form, you should nest a form to create an Item object. To follow the Book example, you'll have something like this: hope this helped you ;).
Apeacox, Thank you for your response. I watched a Ryan Bates video the other day, and I somewhat understood Polymorphic relations. S example of a comment being applicable to different models made sense.
I had a feeling I might need to apply the polymorphic relation here as well. Please verify if this the best approach: BOOK,FURNITURE all belong to model CATEGORY, which belongs to ITEM, or ITEM has one category(BOOK,or FURNITURE). Do I need the model category at all?
If I do I would assume that I would make the ITEM model a polymorphic one, that can belong to any one of 3 CATEGORIES. Right? – BriteLite Jun 25 '10 at 18:39 yes, if you make Item polymorphic, it can belong to one of the 3 categories.
You'll refer to them as 'category' (see the example in my answer). So an @item can do @item. Category_id and @item.
Category_type to know the exact object (class and id of the model), then you can refer to @item.category. Isbn if the category is a Book or @item.category. Price if it's a Furniture – Andrea Pavoni Jun 26 '10 at 8:00.
I am not sure where I have went wrong or even if having multiple has_one relationship works in this case so any advice would be appreciated. I would appreciate if someone could help me out in identifying where I have went wrong. If in the case that I should not be creating such multiple relationships, I would like to have some advice on how could I actually render out 3 forms with a default field indicating the lesson type.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.