Tree view using UITableview

I need to display the following hierarchical data in a UITable View plz to give some suggestion the data will be from plist and will be in the following form:


item 0:
            NODEID:0
            PARENTID:0
            LEVEL:0
            CHLID NODES: (NSARRAY)
                 item 0:
                        NODEID:0
                        PARENTID:0
                        LEVEL:0
                        CHLID NODES: (NSARRAY)
            up to n level

    item 1:
            NODEID:0
            PARENTID:0
            LEVEL:0
            CHLID NODES: (NSARRAY)

      

First of all, I am using the section header for the top level nodes, and at runtime I want it to expand when the user clicks the button. Since insert a row in n number of sections and update the data source.

+3


source to share


1 answer


You have to find child nodes on the fly.

NSPredicate*thePredicate=
[NSPredicate predicateWithFormat:@"SELF.mNodeID == %@",aNodeID];
    NSArray*theChildNodes=[NSArray arrayWithArray:[mNodes filteredArrayUsingPredicate:thePredicate]];

      



Filter the nodes by nodeID to get the child nodes as soon as the user clicks the button to expand the row.

enter image description here

0


source







All Articles