Hi all,
I have had many users report that my app isn’t behaving properly.
I assume that when using Xojo.core.Dictionary.Clone, any changes to a value in the cloned dictionary will leave the “master” dictionary unchanged, at the condition that the value or key is not a class instance.
But this doesn’t seem to be the case.
According to the Xojo docs for Xojo.core.Dictionary.Clone
Is a Text array a class ?
The code has been simplified to the following:
Dim dic1, dic2 As Xojo.Core.Dictionary
//Initialize dic1
dic1 = new Xojo.Core.Dictionary
Dim tArray() As Text
tArray.Append "1"
tArray.Append "2"
dic1.Value("") = tArray
//Cloning dic1
//Assuming that cloning also clones all internal objects that aren't a class.
//Is a text array even an object??
dic2 = dic1.Clone
Dim tArray2() As Text = dic2.Value("")
//Removing one element from text array in dic2
//Which should leave dic1 unchanged because it was cloned
tArray2.Remove(1)
//Counting elements in each text array
Dim cnt1, cnt2 As Integer
Dim a() As Text
a = dic1.Value("")
cnt1 = a.Ubound
a = dic2.Value("")
cnt2 = a.Ubound
if cnt1 = cnt2 then
Break //This shouldn't happen
end if