MobileTable - listing a directory

Ive been struggling with filling a listbox with the contents of a directory, plus subfolders (1 level only)

Easy enough to list the contents of one folder- I can (for example) fill an array with all the files it contains which I ‘like’ (not all files will be listed)
The RowData method asks for a row number, and what I send back is the array element that matches the row. Easy

But if there are subfolders, and I want to make them look like sections?
I can count the sections, I can name the sections.
But there is a disconnect between sectionnumber and row number that I cannot get my head around.

If the row is ‘row within a section’, I’ve kinda lost count of where I am by the time we are into a section.

Has anyone made a similar file lister in iOS and can give me a hint about how to get it ‘right’?

For example, the folder structure might be:

{root}
file1.txt
file2.txt
\banana
    pea.txt
    carrot.txt
\apples
   braeburn.txt

And I would want to see


[    ]
file1.txt
file2.txt
[apples]
braeburn.txt
[banana]
pea.txt
carrot.txt

given that the mobiletable isn’t hierarchical