iPhone giving different results than simulator.Saving data

I have a game where I have a regular score, and a highscore… On the corona simulator, everything works fine, although on my iphone, it doesnt work. I am using an extra script for saving that is called preference.lua(i found it here - http://developer.coronalabs.com/code/save-data-files-tablesnumbersstringsboolean  ). Here is my code for scoring and highscoring.

[lua]

–SCORING

score = 0

local function updateScore()

score = score + 1

end

timer.performWithDelay(300, updateScore,

–HIGHSCORING

local preference = require “preference”

highScore = preference.getValue(“a”)

local function updateHighScore()

if (score > highScore) then

preference.save{a = score}

highScore = preference.getValue(“a”)

end

end

timer.performWithDelay(1, updateHighScore, -1)

[/lua]

On the simulator, it saves the highscore and puts it in text, but when it reaches the line to display the highscore, it stops there, which means that either its not saving the value, or something’s wrong in my highScore code(but it works in the simulator).

Why are you calling updateHighScore every millisecond over and over?

Also if that’s your actual code (meaning you copy/pasted not hand typed), there is a typo in line 9.  You never close your parens on that timer call.

But with firing that timer so fast you could be overwriting the file too quickly and its possible a different in the computer OS and the Phone OS could do that.

Line 9 was a typo here, but it was correct in my real file. I changed it so that it would only save if the player died, and it still did not work. Here is where i call back the highscore(line 4) and everything stops after it hits that line of code. is there anything obvious that I am missing?

[lua]

local endingtext = display.newText( “GAME OVER”, 55, 60, nil, 50)

local scorertext = display.newText( "SCORE - - "…score, 40, 260, nil, 50)

local highscorertext = display.newText("HighScore - - ", 40, 360, nil, 50)

local highScoreText = display.newText(highScore, 400, 360, nil, 50)

[/lua]

Why are you calling updateHighScore every millisecond over and over?

Also if that’s your actual code (meaning you copy/pasted not hand typed), there is a typo in line 9.  You never close your parens on that timer call.

But with firing that timer so fast you could be overwriting the file too quickly and its possible a different in the computer OS and the Phone OS could do that.

Line 9 was a typo here, but it was correct in my real file. I changed it so that it would only save if the player died, and it still did not work. Here is where i call back the highscore(line 4) and everything stops after it hits that line of code. is there anything obvious that I am missing?

[lua]

local endingtext = display.newText( “GAME OVER”, 55, 60, nil, 50)

local scorertext = display.newText( "SCORE - - "…score, 40, 260, nil, 50)

local highscorertext = display.newText("HighScore - - ", 40, 360, nil, 50)

local highScoreText = display.newText(highScore, 400, 360, nil, 50)

[/lua]