iOS Question How can I modify a Value of a Map

Israel Gallegos

Member
Licensed User
I try modify a value in my map with function map.put, I set the key and the new value but not Works

I tried too Remove first the Key and after insert again

help me please
 

Attachments

  • Captura de Pantalla 2021-12-21 a la(s) 11.43.07 (2).png
    Captura de Pantalla 2021-12-21 a la(s) 11.43.07 (2).png
    47.1 KB · Views: 255
  • Captura de Pantalla 2021-12-21 a la(s) 11.45.04.png
    Captura de Pantalla 2021-12-21 a la(s) 11.45.04.png
    23.3 KB · Views: 241

hatzisn

Expert
Licensed User
Longtime User
You do not show your entire code but it should be the immutable "bug" of maps in B4i (maybe objective C feature) which the only way to face it is to recreate the map. Copy all keys with values to a new map and set this to the given map. You can do this with a function where you send as argument your map and what the function returns you set it to the same map. Of course you will create the function which will return a map. This happens when you recreate map or list of maps from a JSON.
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
this does not work?
B4X:
Public Sub TestMap
    Dim map1 As Map
    map1.Initialize
    
    'Add
    map1.Put("vchUUID", "New")
    Log(map1.As(JSON).ToString)
    
    'Update
'    map1.Remove("vchUUID")
    map1.Put("vchUUID", "Update")
    Log(map1.As(JSON).ToString)
    
End Sub

see:
 
Upvote 0

Israel Gallegos

Member
Licensed User
You do not show your entire code but it should be the immutable "bug" of maps in B4i (maybe objective C feature) which the only way to face it is to recreate the map. Copy all keys with values to a new map and set this to the given map. You can do this with a function where you send as argument your map and what the function returns you set it to the same map. Of course you will create the function which will return a map. This happens when you recreate map or list of maps from a JSON.
Thank`s
 
Upvote 0

Israel Gallegos

Member
Licensed User
this does not work?
B4X:
Public Sub TestMap
    Dim map1 As Map
    map1.Initialize
   
    'Add
    map1.Put("vchUUID", "New")
    Log(map1.As(JSON).ToString)
   
    'Update
'    map1.Remove("vchUUID")
    map1.Put("vchUUID", "Update")
    Log(map1.As(JSON).ToString)
   
End Sub

see:

No :( I want to modify a map set before and after update only one a value of this same map, but not refresh


I Tried this:


'Update
' map1.Remove("vchUUID")
map1.Put("vchUUID", "Update")
Log(map1.As(JSON).ToString)

I had to create a new one map as told hatzisn
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
No :( I want to modify a map set before and after update only one a value of this same map, but not refresh


I Tried this:


'Update
' map1.Remove("vchUUID")
map1.Put("vchUUID", "Update")
Log(map1.As(JSON).ToString)

I had to create a new one map as told hatzisn
Thank you.

I needed to know if it allowed to add and update map elements directly.

On B4A and B4J, if you allow it, I have tried it.

I ask this because I have not used the latest versions of B4i and hope to use it in the near future.

regards.
 
Upvote 0
Top