Filling different sections in a tableview

Discussion in 'iPhone/iPad Programming' started by VeniVidiVici-NL, Jun 22, 2010.

  1. macrumors newbie

    Joined:
    Jun 22, 2010
    #1
    Hey guys,

    I'm fairly new to programming and I ran into a problem while working on an app. I've made three sections in my table view (not alphabetic, but each section represents a subject). Now i also have 3 arrays which I want to show in the corresponding sections.
    But here's my problem, how do i tell the tableview which array has to be displayed in which section?

    I already have the number of rows laid out in each section.

    Hope you can help me :)
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
  3. thread starter macrumors newbie

    Joined:
    Jun 22, 2010
    #3
    Oke, now i've got a filled tableview. But, now all the sections use the same array. So the first sections displays the first word of my array, the second section displays the second word and so on. I want each array in a different section.

    Never mind, i got it worked out. I just needed to tell that there is a row and a section and then i could use an if-statement.

    Thanks for the help!
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Then your code is wrong. Either post it and hope someone is kind enough to fix it for you or fix it yourself.
     
  5. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #5
    The way to do this is to make a single data structure that represents the data for the table. It needs to have a structure similar to the structure of the table. I use an array of arrays of dictionaries usually.

    Each dictionary represents the data for a row. The top level array represents the list of sections. The second level arrays each represent a section.

    All the code for the tableview callbacks becomes very simple if you set things up like this.
     
  6. macrumors newbie

    Joined:
    Dec 20, 2010
    #6
    Post Code

    Can you post on how you ended up solving the problem..I'm basically doing the same thing and I'm stuck with just getting the same array coming up.

    Thanks,
    Matt
     

Share This Page