*Edited to include Kyatric's feedback about the UID not changing.*
I gained insight about UID and IID by reading some forums posts. Here is my attempt to summarize the two.
C2 increments the UID every time an instance of any object is spawned. C2 increments IID every time an instance of a specific object is spawned.
Remember that C2 is spawning instances of the circle, square and triangle object types. Also, indexes are zero based so they start at 0 not 1.
Here's an example. Lets say we have three sprites a circle, a square and a triangle. We tell C2 to spawn 3 circles then 3 squares and then 3 triangles. The UID will increase each time any objects are spawned while the IID will only increase when an instance of a specific object type spawns, for example Circle.
UID IID
Circle 1 0 0
Circle 2 1 1
Circle 3 2 2
Square 1 3 0
Square 2 4 1
Square 3 5 2
Triangle 1 6 0
Triangle 2 7 1
Triangle 3 8 2
There isn't a right or wrong way to use UID or IID. Your use of UID or IID depends on what you are trying to do. If you want to select the 2nd square you could use the UID of 4 or the Square.IID of 1. Both will give you the same result.
Something to keep in mind is that the UID and IID will change if you destroy one of the object instances. Using the table from above, if we delete the second instance of the square object type the values will change like this.
UID IID
Circle 1 0 0
Circle 2 1 1
Circle 3 2 2
Square 1 3 0
Square 3 5 1*
Triangle 1 6* 0
Triangle 2 7* 1
Triangle 3 8* 2
Notice how Square 3 is now the 2nd instance of the square object and it's IID changed to 1? You should also notice that the UID of Square 3 stayed the same. All of the triangle UID and IID values stayed the same.