Folderitem.Count .TrueChild

In the Xojo documentation, it’s written an example :

Dim dir As FolderItem = SpecialFolder.Desktop Dim dirCount As Integer = dir.Count For itemIdx As Integer = 1 To dirCount Dim item As FolderItem = dir.TrueItem(itemIdx) If item <> Nil Then ListBox1.Addrow(item.Name) End If Next
I don’t understand how item can be Nil.
But it’s not the only things which is strange.
I have a folder in which I create subfolder, and I take all those subfolders to make a menu.
If A do :

Fin_iNbre = MyParentFolder.Count ' Folder in which I create my subfolder For iNbre = 1 to Fin_iNbre MySubFolder = MyParentFolder.TrueItem(iNbre) If not(MySubFolder = Nil) Then MyMenu.Addrow MySubFolder.Name Next iNbre
The subfolder I just created is not there, even if I launch this in a Timer after have created my SubFolder.
But if I do :

Fin_iNbre = Min(MyParentFolder.Count, 2) ' Folder in which I create my subfolder For iNbre = 1 to Fin_iNbre ' I do not need to loop in all items, just 1 or 2 (I loop 2) MySubFolder = MyParentFolder.TrueItem(iNbre) ' I don't do anything, just call a item in my ParentFolder Next iNbre Fin_iNbre = MyParentFolder.Count ' Folder in which I create my subfolder For iNbre = 1 to Fin_iNbre MySubFolder = MyParentFolder.TrueItem(iNbre) If not(MySubFolder = Nil) Then MyMenu.Addrow MySubFolder.Name Next iNbre
It’s ok, I have the folder I juste created and I do not need to launch it in a timer, I can do that just after create my SubFolder.
I just wonder why it works. I don’t like when my application doesn’t work and I don’t know why, but I always finish to find the problem. I dislike when I application work and I never know why.

Edit : I forget to mention I’m under Mac OS X El Capitan.

TrueItem and TrueChild return folderitems which may not actually exist in the folder you are looking at
They resolve aliases and shortcuts

So if you have a folder A, which holds a folder B, and a SHORTCUT to a folder C which is on another drive,
the count will be 2
The .child that points to B gives you a folder inside A
the .child that points to C is just a shortcut
the .truechild from C is a folder, but it is not a folder that is inside A

You probably shouldnt be using .truechild or .trueitem here.

Where is the folder you just created?
Are you using Dropbox?

It’s the opposite no? .TrueChild returns the Alias, and .Child returns the Target of the Alias. (I’m not sure to understand, what you call a shortcut is what I call an Alias ?).

I create my folder in MyParentFolder which is a folder in my HardDrive.