Saving indexed data in tableview using GGData

Sorry that was my mistake, serves me right for replying before coffee.

You’ll need to put the ‘checked’ table back into GGData after you’ve edited the value in your onPress function like this:

settings:set( "checked", checked ) settings:save()

Finally! :D 
It’s working. Thanks!
Keep on making great libraries and apps!

Glad it’s working and we’re sure going to try  :slight_smile:

i have another question
My box looks like this
 

 local box = widget.newSwitch { style = "checkbox", --id = "Checkbox button", onPress = onSwitchPress, initialSwitchState = false or settings:get( "checked" )[row.index] }

When i start my app for the first time I get “attempt to index a nil value” error. If I replace initialSwitchState field to just “false” the app starts normally. When I set some value for “checked” I can then replace it with “initialSwitchState = false or settings:get( “checked” )[row.index]”  and it works okay. 
 

You are essentially using what is called a ternary operator there with this line:

initialSwitchState = false or settings:get( "checked" )[row.index]

What that is saying is set the ‘initialSwitchState’ value to ‘false’ if ‘false’ is equal to ‘true’ ( which it isn’t ) or set it to the value in the GGData box. As you have it now it is the same as this:

initialSwitchState = settings:get( "checked" )[row.index]

And it’s failing as it’s trying to set it to nil until you set that GGData value with something.

I’m assuming you are trying to set the state of the checkbox to the value in the GGData box and if that isn’t set then set it to false? ( which is strange as I was doing that exact thing today as I was putting a settings screen in our new game ). If so you want to change it to this:

initialSwitchState = settings:get( "checked" )[row.index] or false

Hope that helps!

initialSwitchState = settings:get( "checked" )[row.index] or false

Got the same error.
Luckily, I have already overcome the problem with this:
 

local switchState if settings:get( "checked" ) == nil then switchState = false else switchState = settings:get( "checked" )[row.index] end local box = widget.newSwitch { style = "checkbox", --id = "Checkbox button", onPress = onSwitchPress, initialSwitchState = switchState }

Glad you got it working!