iOS Question UnReadOnly Map.IsReadOnly?

Mashiane

Expert
Licensed User
Longtime User
You will need to copy the map. You can do it manually or use B4XSerializator (iRandomAccessFile library)
B4X:
Sub CopyMap(m As Map) As Map
   Dim ser As B4XSerializator
   Return ser.ConvertBytesToObject(ser.ConvertObjectToBytes(m))
End Sub
Thanks a lot, thought of such and had already written a loop function. This will do..
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
You will need to copy the map. You can do it manually or use B4XSerializator (iRandomAccessFile library)
B4X:
Sub CopyMap(m As Map) As Map
   Dim ser As B4XSerializator
   Return ser.ConvertBytesToObject(ser.ConvertObjectToBytes(m))
End Sub
I had done this...

B4X:
Sub UnReadOnlyMap(sourceMap As Map) As Map
    ' copy a map to a new map to make it IsReadOnly = False
    If sourceMap.IsReadOnly = False Then Return sourceMap
    ' the map is readonly, convert it
    Dim newMap As Map
    newMap.Initialize
    ' copy each map item
    For Each key As String In sourceMap.Keys
        Dim val As Object = sourceMap.Get(key)
        newMap.Put(key,val)
    Next
    Return newMap
End Sub
 
Upvote 0
Top