I have a question regarding the method communication from Lua to Swift.
I know that Lua has a special way to handle arrays & associative arrays as the same kind of objects.
Here is the situation:
Let’s say I fill an array with the players ids.
local playersIds = {} table.insert(playersIds, ‘Player A’) table.insert(playersIds, ‘Player B’)
Then I send this array to the app.
local event = { name=‘coronaView’, event=‘PlayersIdsUpdated’, playersIds=playersIds } Runtime:dispatchEvent(event)
I would expect to receive a NSArray/Array in the app. Instead, I’m receiving a Dictionary<Int,String>.
The thing is that I want to convert this list to JSON, and send it somewhere.
But the JSONSerializationclass on iOS doesn’t handle Dictionary<Int** ,String **> values. The conversion just fails.
I know, there are a lot of solutions here, and it’s not a real problem.
As I’m just starting Lua & Corona, I was just wondering if there is a way to get directly a NSArray from Corona, without implementing something specific in Swift.
table.insert(playersIds, ‘something’) or playersIds[#playersIds + 1] = ‘something’ will both populate your array starting at index 1, rather than 0. Might this be throwing off some sort of array-vs.-dictionary detection?
table.insert(playersIds, ‘something’) or playersIds[#playersIds + 1] = ‘something’ will both populate your array starting at index 1, rather than 0. Might this be throwing off some sort of array-vs.-dictionary detection?