I’m working on my first iOS app, one which involves two screens: a main working (timer) screen, and a configuration screen. I press the Configure button to go to the configuration screen, and the Start button from the configuration screen to come back. On the simulator, this works as expected. On the device, even though the Start button highlights indicating that it was clicked, the screen switch never takes place and I am trapped in the configuration screen.
The code to return from the configuration screen includes the following:
function store()
local val
for i = 1, 6 do
main.set.player[i] = name[i].text
if name[i].text==nil then val=“nil” else val=name[i].text end – FOR DEBUG
print (“name[”…tostring(i)…"].text="…val) – FOR DEBUG
– HERE’S THE BUG >>> if (name[i].text > " ") then main.set.nPlayers = i end
end
end
Here is my observation: in the simulator, when the user has left the native text field empty, name[i].text comes back as an empty string. But on the actual iPhone, name[i].text comes back as nil, and my comparison leads to a crash:
Lua Runtime Error: lua_pcall failed with status: 2, error message is:
…Desktop/Programs/Corona/MicroBiz Timer/configure.lua:87: attempt to compare string with nil
Just today, hoping to beat the problem before I understood it, I upgraded from Corona 2012.971 to 2013.2076. But no, this discrepancy has persisted throughout that entire year.
I would argue that nil should compare as equivalent to the empty string when compared with strings, rather than producing a runtime error. But regardless, I hope you can fix the libraries so they handle this situation the same on the simulator and on the phone.
Ken
The phone: iPhone 5 / iOS 6.1.4