I have these functions:
local function loadHighScoreData()
local fileContent ="";
local path = system.pathForFile("highScoreData.json", system.DocumentsDirectory);
local file = io.open(path, "r");
fileContent = file:read("\*a");
io.close(file);
return fileContent;
end
local function saveHighScoreData (data)
local path = system.pathForFile("highScoreData.json", system.DocumentsDirectory);
local file = io.open(path, "w+");
local fileContent = file:read("\*a");
local newData = data;
file:write(newData);
io.close(file);
end
Which can be invoked this way:
[code]local loadHighScoreData = loadHighScoreData();
saveHighScoreData(’{“scores”:{1:[“John”,60],2:[“Jude”,60],3:[“Max”,60],4:[“Kyle”,60],5:[“Smith”,60],6:[“Mark”,50],7:[“Luke”,40],8:[“Anne”,30],9:[“Bruce”,20],10:[“Carl”,0]}}’);
[/code]
I have tested these functions out on the Corona Simulator and they have been working perfectly. When I tried building the app for the Xcode Simulator, the scene where those functions are used suddenly break down.
I have isolated the case and found that the line in the loadHighScoreData() which causes this is:
fileContent = file:read("\*a");
What can I do to make it work on the Xcode Simulator?
Any help would be greatly appreciated.
Regards,
John [import]uid: 177058 topic_id: 31175 reply_id: 331175[/import]