Hi, the issue seemed to be with Ice so I ended up writing my own code for storing/fetching data.
[code]
– Project: Settings
– Version: 1.0
– Author: Johan Johansson @ Baboons.se
– Support: www.baboons.se
– Copyright © Baboons. All Rights Reserved.
– Require Json
local json = require(“json”)
–Initialize object
local settings = { }
function settings:set(key, value)
self.data[key] = value
self:save()
end
function settings:get(key)
if self.data then
return self.data[key]
else
return nil
end
end
function settings:remove(key)
self.data[key] = nil
end
function settings:increment(key)
local value = self:get(key) or 0
value = value + 1
self.data[key] = value
self:save()
end
function settings:decrement(key)
local value = self:get(key) or 0
value = value - 1
self.data[key] = value
self:save()
end
function settings:hasValue(key)
if self.data then
if self.data[key] then
return true
else
return false
end
else
return false
end
end
function settings:save()
local path = system.pathForFile(self.file, system.DocumentsDirectory)
local fh = io.open(path, “w”)
fh:write(json.encode(self.data))
fh:close()
end
function settings:clear()
for key, value in pairs(self.data) do
self:remove(key)
end
self:save()
end
function settings:load(name, extension)
local extension = extension or ‘json’
local file = name … ‘.’ … extension
local o = { file = file }
local path = system.pathForFile(file, system.DocumentsDirectory)
local fh, reason = io.open(path, “r”)
if fh then
– read all contents of file into a string
local contents = fh:read("*a")
local succ, data = pcall(function()
return json.decode(contents)
end)
if succ then
o.data = data
else
o.data = {}
end
else
– print("Coulnd’t load settings: " … reason)
o.data = {}
end
setmetatable(o, self)
self.__index = self
return o
end
return settings
[/code] [import]uid: 106083 topic_id: 21532 reply_id: 103450[/import]