views:

27

answers:

1

after parse xml. xml attributes data i stored in NSMutableArray *anArray; which is in MyAppDelegate. I used anArray in MyAppDelegate.

For my xml i do have One root Tag and N number Child tag.

my xml example:

  <root>
    <child name1="",name2="",name3=""/>
    <child name1="",name2="",name3=""/>
    <child name1="",name2="",name3=""/>
    </root>

i parsed data perfectly and i displayed name1 on table View..... When i navigated it used didSelectRowAtIndexPath. And i loaded the nib file. which has tableview IBOutlet. i set class for my nib....datasource and delegate to the file owner every thing work perfectly. navigation stuff work perfectly....

now i need load data into second nib file tableview name2 and name3 values. but it displaying only name2 values. what to do .. I used the above code in my controller class. for second nib.

  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
        return 1;
    }
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section     {
        return [appDelegate.anArray count]; 
    }

    - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        }


        DetailsView *detailsview=[appDelegate.anArray objectAtIndex:indexPath.row];
        switch (indexPath.section) {
            case 0:
                cell.textLabel.text=detailsview.name1;
                break;
                case 1:
                cell.textLabel.text=detailsview.name2;
                    break;
                            default:
                break;
    }
    return cell;
    }
A: 

In your method numberOfSectionsInTableView you say that your table view has only one section. Then in the cellForRowAtIndexPath method you do a switch on the section. Based on the code above, only name1 should be displayed, because your section will always be 0.

Stelian Iancu
@Thanks stelian lancu........
kiran kumar