iOS Question Missing GetValueAt on MAP

Shay

Well-Known Member
Licensed User
Longtime User
This is from B4A, how do I do it on B4i, there is no GetValuteAt
B4X:
 For i=0 To CityMap.Size-1
      City = CityMap.GetValueAt(i)
      If City.CompareTo(Main.MYCity) = 0 Then
       Main.MyCityCode = CityMap.GetKeyAt (i)
       Log("Got City Code")
       i = CityMap.Size - 1
      End If
     Next
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
See this link: https://www.b4x.com/android/forum/threads/missing-function-map.46971/
Seems to me that you are not using the map correctly (or in the best way).

If you need to look for a value then either switch the keys and values or use a second map that maps between the cities and the codes.

However you can use this code:
B4X:
For Each CityCode As String in CityMap.Keys
 Dim City As String = CityMap.Get(CityCode)
 If City.CompareTo(Main.MyCity) = 0 Then
  Main.MyCityCode = CityCode
  Exit
 End If
Next
 
Upvote 0
Top