Why is this crashing?

Whenever I run this code, after I have purchased something and it shifts up after leaving and reopening the page it crashes with the error "Index out of range".

Ideas? Thanks in advance!

Ps: I can provide full project if needed.
Answered by Mcrich23 in 674573022
I fixed it again by instead of using num unlocked using unlocked.count and locked.count.

Once an icon gets purchased, setIconPurchased gets set to true, and then if it equals true it does more actions.

Then your code is quite right. Please go on with your current code.

Once an icon gets purchased, setIconPurchased gets set to true, and then if it equals true it does more actions.

If so, why don't you launch the other action in the same func where you set setIconPurchased to true ?

But the overall problem is that your code is too complex. One reason is that you store ate of cells in different arrays that you need to sync.
Why is this crashing?
 
 
Q