iOS Question List in Map expected NSArray

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,

when I try to read a List (which contains Maps) from a Map I get a error:
Expected: NSArray, object type: __NSCFString

Attached you can find a example project which demonstrates the issue.
Any help?

Jan
 

Attachments

  • problem.zip
    1 KB · Views: 156

Erel

B4X founder
Staff member
Licensed User
Longtime User
File.WriteMap / ReadMap create text files. They only work with strings and numbers.

You should use B4XSerializator instead:
B4X:
Private Sub WriteMap(m As Map, Dir As String, FileName) As String
   Dim ser As B4XSerializator
   Dim out As OutputStream = File.OpenOutput(Dir, FileName, False)
   Dim b() As Byte = ser.ConvertObjectToBytes(m)
   out.WriteBytes(b, 0, b.Length)
   out.Close
End Sub

Private Sub ReadMap (Dir As String, FileName) As Map
   Dim ser As B4XSerializator
   Return ser.ConvertBytesToObject(Bit.InputStreamToBytes(File.OpenInput(Dir, FileName)))
End Sub
 
Upvote 0
Top